Add ASYNC233 pathlib blocking call rule - #467
Conversation
Zac-HD
left a comment
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>`_ |
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.
| 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`_. |
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.
jakkdl
left a comment
There was a problem hiding this comment.
the implementation looks suspiciously big to me, when all the other ASYNC23X rules are very compact. It looks a bit like my early attempts at getting LLM's to help when models were less capable and couldn't properly juggle an AST and make use of the helpers properly.
It looks like it's parsing annotations, but there's a utility visitor for doing that.
So, I would like to hear the motivation for why all this plumbing is required - and if it even makes sense to mash it into Visitor23X.
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.