Skip to content

Various small fixes#445

Merged
Zac-HD merged 5 commits intopython-trio:mainfrom
Zac-HD:claude/fix-flake8-async-422-171t7
Apr 21, 2026
Merged

Various small fixes#445
Zac-HD merged 5 commits intopython-trio:mainfrom
Zac-HD:claude/fix-flake8-async-422-171t7

Conversation

@Zac-HD
Copy link
Copy Markdown
Member

@Zac-HD Zac-HD commented Apr 21, 2026

fixes #268, fixes #310, fixes #398, fixes fixes #422.

claude added 5 commits April 21, 2026 20:41
In tox 4, `tox -e ""` is treated as "no env specified" and falls back
to the default envlist, so the "Run tests without flake8" step was
running every `py3xx-flake8` env whose interpreter tox could discover
on the runner (including the system Python 3.12), instead of a single
no-flake8 test run. Replace the trailing-comma empty env with a proper
`[testenv:no_flake8]` section and point CI at it.

Also allow `return asyncio.create_task(...)`: treat `Return` like
`Assign` in Visitor300, since the caller preserves the task.

Fixes python-trio#422
Fixes python-trio#398
1. Document using ruff's `lint.external` setting so that `# noqa: ASYNC...`
   comments survive when both ruff and flake8-async are in use.

4. Apply the `self.novisit = True` fix proposed in python-trio#307 at the end of
   `Visitor102.visit_Try`. The previous code happened to work because
   the internal `visit_nodes` calls left `self.novisit` True on exit,
   but relying on that is fragile; making it explicit matches the
   pattern used elsewhere and documents the intent.
ast.parse() accepts some code the bytecode compiler rejects (e.g.
`x = lambda: await foo()`, `return` outside a function), so a bad
test fixture could silently slip past the plugin's ast-based checks.

Add a new parametrized test that runs compile() on every
tests/eval_files/*.py. A handful of existing fixtures intentionally
contain such constructs to exercise edge cases; mark those with a new
`# NOCOMPILE` magic marker so the new test skips them while still
leaving the rest of the suite guarding against accidents.

Fixes python-trio#268
Docs and test changes aren't user-visible, so they don't need a
changelog entry. The ASYNC300 behaviour change stays.
Python 3.10's compile() rejects nested async comprehensions inside an
async function with "asynchronous comprehension outside of an asynchronous
function"; 3.11 became permissive here. The file parses fine with
ast.parse on every supported version, which is all the plugin needs,
so tag it with the existing # NOCOMPILE marker (also in the matching
autofix fixture to keep the diff clean).
@Zac-HD Zac-HD merged commit 963d4df into python-trio:main Apr 21, 2026
10 checks passed
@Zac-HD Zac-HD deleted the claude/fix-flake8-async-422-171t7 branch April 21, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra (unnecessary) 3.12 test run in CI ASYNC300 should allow return asyncio.create_task(...) Various minor things run compile() on eval_files

2 participants