Add ASYNC233 pathlib blocking call rule - #467
Open
paranoa233 wants to merge 3 commits into
Open
Conversation
Zac-HD
reviewed
Jul 28, 2026
Zac-HD
left a comment
Member
There was a problem hiding this comment.
Small docs and changelog note; otherwise looks great - thanks @paranoa233!
|
|
||
| 26.6.1 | ||
| ====== | ||
| - Add :ref:`ASYNC233 <async233>` blocking-pathlib-call to detect blocking ``pathlib.Path`` I/O methods in async functions. `(issue #396) <https://github.com/python-trio/flake8-async/issues/396>`_ |
Member
There was a problem hiding this comment.
new heading for this (26.7.2 - you might want to rebase), since it'll be a new release.
Comment on lines
+194
to
197
| Blocking sync call to ``pathlib.Path`` I/O methods in async function, use :class:`trio.Path`/:class:`anyio.Path`. ``asyncio`` users should consider `aiopath <https://pypi.org/project/aiopath>`__ or `anyio`_. | ||
|
|
||
| ASYNC240 : blocking-path-usage | ||
| Avoid using :mod:`os.path` in async functions, prefer using :class:`trio.Path`/:class:`anyio.Path` objects. ``asyncio`` users should consider `aiopath <https://pypi.org/project/aiopath>`__ or `anyio`_. |
Member
There was a problem hiding this comment.
I think in each case I'd recommend that asyncio users use anyio.Path objects on asyncio backend (it's automatic and therefore easy), rather than aio- libs; I just can't trust the latter as much.
It's fine if you'd rather leave that for someone else's later PR though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #396.
Summary
Test Plan
python -m pytest tests/test_flake8_async.py -k "ASYNC233 or ASYNC212"python -m pytest tests/test_messages_documented.py tests/test_all_visitors_imported.pypython -m ruff check flake8_async tests docsFull
python -m pyteston Windows: 1180 passed, 170 skipped; 2 existing CLI-output assertions fail because local subprocess output uses CRLF/path separators.