You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add async124 async-function-could-be-sync
* fixed two bugs in async91x
* enable no_checkpoint_warning_decorators for async124. Remove unused Visitor91x.safe_decorator.
* mention ASYNC124 in docs/usage.rst, and convert mentions of PEP to :pep:
- :ref:`ASYNC91x <ASYNC910>` now correctly handles ``await()`` in parameter lists.
11
+
- Fixed a bug with :ref:`ASYNC91x <ASYNC910>` and nested empty functions.
12
+
7
13
24.11.4
8
14
=======
9
15
- :ref:`ASYNC100 <async100>` once again ignores :func:`trio.open_nursery` and :func:`anyio.create_task_group`, unless we find a call to ``.start_soon()``.
@@ -238,7 +244,7 @@ Changelog
238
244
239
245
22.9.2
240
246
======
241
-
- Fix a crash on nontrivial decorator expressions (calls, PEP-614) and document behavior.
247
+
- Fix a crash on nontrivial decorator expressions (calls, :pep:`614`) and document behavior.
``yield`` inside a :ref:`taskgroup_nursery` or :ref:`timeout_context` is only safe when implementing a context manager - otherwise, it breaks exception handling.
21
21
See `this thread <https://discuss.python.org/t/preventing-yield-inside-certain-context-managers/1091/23>`_ for discussion of a future PEP.
22
-
This has substantial overlap with :ref:`ASYNC119 <ASYNC119>`, which will warn on almost all instances of ASYNC101, but ASYNC101 is about a conceptually different problem that will not get resolved by `PEP 533 <https://peps.python.org/pep-0533/>`_.
22
+
This has substantial overlap with :ref:`ASYNC119 <ASYNC119>`, which will warn on almost all instances of ASYNC101, but ASYNC101 is about a conceptually different problem that will not get resolved by :pep:`533`.
23
23
24
24
_`ASYNC102` : await-in-finally-or-cancelled
25
25
``await`` inside ``finally``, :ref:`cancelled-catching <cancelled>` ``except:``, or ``__aexit__`` must have shielded :ref:`cancel scope <cancel_scope>` with timeout.
``yield`` in context manager in async generator is unsafe, the cleanup may be delayed until ``await`` is no longer allowed.
79
-
We strongly encourage you to read `PEP 533 <https://peps.python.org/pep-0533/>`_ and use `async with aclosing(...) <https://docs.python.org/3/library/contextlib.html#contextlib.aclosing>`_, or better yet avoid async generators entirely (see `ASYNC900`_ ) in favor of context managers which return an iterable :ref:`channel/stream/queue <channel_stream_queue>`.
79
+
We strongly encourage you to read :pep:`533` and use `async with aclosing(...) <https://docs.python.org/3/library/contextlib.html#contextlib.aclosing>`_, or better yet avoid async generators entirely (see `ASYNC900`_ ) in favor of context managers which return an iterable :ref:`channel/stream/queue <channel_stream_queue>`.
80
80
81
81
_`ASYNC120` : await-in-except
82
82
Dangerous :ref:`checkpoint` inside an ``except`` block.
Dropping this information makes diagnosing errors much more difficult.
96
96
We recommend ``raise SomeNewError(...) from group`` if possible; or consider using `copy.copy` to shallow-copy the exception before re-raising (for copyable types), or re-raising the error from outside the `except` block.
97
97
98
+
_`ASYNC124`: async-function-could-be-sync
99
+
Triggers when an async function contain none of ``await``, ``async for`` or ``async with``.
100
+
Calling an async function is slower than calling regular functions, so if possible you
101
+
might want to convert your function to be synchronous.
102
+
This currently overlaps with :ref:`ASYNC910 <ASYNC910>` and :ref:`ASYNC911 <ASYNC911>` which, if enabled, will autofix the function to have :ref:`checkpoint`.
103
+
This excludes class methods as they often have to be async for other reasons, if you really do want to check those you could manually run :ref:`ASYNC910 <ASYNC910>` and/or :ref:`ASYNC911 <ASYNC911>` and check the methods they trigger on.
Comma-separated list of decorators to disable checkpointing checks for, turning off :ref:`ASYNC910 <async910>` and :ref:`ASYNC911 <async911>` warnings for functions decorated with any decorator matching against an entry in the list.
218
+
Comma-separated list of decorators to disable checkpointing checks for, turning off :ref:`ASYNC910 <async910>`, :ref:`ASYNC911 <async911>`, and :ref:`ASYNC124 <async124>` warnings for functions decorated with any decorator matching against an entry in the list.
219
219
Matching is done with `fnmatch <https://docs.python.org/3/library/fnmatch.html>`_.
220
220
Defaults to disabling for ``asynccontextmanager``.
221
221
222
-
Decorators-to-match must be identifiers or dotted names only (not PEP-614 expressions), and will match against the name only - e.g. ``foo.bar`` matches ``foo.bar``, ``foo.bar()``, and ``foo.bar(args, here)``, etc.
222
+
Decorators-to-match must be identifiers or dotted names only (not :pep:`614` expressions), and will match against the name only - e.g. ``foo.bar`` matches ``foo.bar``, ``foo.bar()``, and ``foo.bar(args, here)``, etc.
0 commit comments