Skip to content

Commit fe26f24

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 20e1521 commit fe26f24

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

doc/data/messages/a/async-context-manager-with-regular-with/bad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ async def async_context():
77

88

99
with async_context(): # [async-context-manager-with-regular-with]
10-
print("This will cause an error at runtime")
10+
print("This will cause an error at runtime")

doc/data/messages/a/async-context-manager-with-regular-with/good.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ async def async_context():
99

1010
async def main():
1111
async with async_context():
12-
print("This works correctly")
12+
print("This works correctly")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
- `PEP 492 - Coroutines with async and await syntax <https://peps.python.org/pep-0492/>`_
2-
- `contextlib.asynccontextmanager <https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager>`_
2+
- `contextlib.asynccontextmanager <https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager>`_
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Add new check ``async-context-manager-with-regular-with`` to detect async context managers used with regular ``with`` statements instead of ``async with``.
22

3-
Refs #10999
3+
Refs #10999

pylint/checkers/typecheck.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,9 @@ def _check_invalid_slice_index(self, node: nodes.Slice) -> None:
18781878
if invalid_slice_step:
18791879
self.add_message("invalid-slice-step", node=node.step, confidence=HIGH)
18801880

1881-
@only_required_for_messages("not-context-manager", "async-context-manager-with-regular-with")
1881+
@only_required_for_messages(
1882+
"not-context-manager", "async-context-manager-with-regular-with"
1883+
)
18821884
def visit_with(self, node: nodes.With) -> None:
18831885
for ctx_mgr, _ in node.items:
18841886
context = astroid.context.InferenceContext()
@@ -1897,8 +1899,9 @@ def visit_with(self, node: nodes.With) -> None:
18971899
async_decorators = ["contextlib.asynccontextmanager"]
18981900
if decorated_with(inferred.parent, async_decorators):
18991901
self.add_message(
1900-
"async-context-manager-with-regular-with", node=node,
1901-
args=(inferred.parent.name,)
1902+
"async-context-manager-with-regular-with",
1903+
node=node,
1904+
args=(inferred.parent.name,),
19021905
)
19031906
continue
19041907
# If the parent of the generator is not the context manager itself,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
async-context-manager-with-regular-with:12:0:13:8::Context manager 'async_cm' is async and should be used with 'async with'.:UNDEFINED
1+
async-context-manager-with-regular-with:12:0:13:8::Context manager 'async_cm' is async and should be used with 'async with'.:UNDEFINED

0 commit comments

Comments
 (0)