add ASYNC125 constant-absolute-deadline#366
Merged
Zac-HD merged 2 commits intopython-trio:mainfrom Apr 2, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces the ASYNC125 error code to detect cases where a constant value is used with timing functions (e.g., fail_at, move_on_at, CancelScope) that expect deadline values relative to the runner clock. The changes include new tests to exercise the ASYNC125 behavior, modifications to error reporting in visitors, and an updated TrioScope constructor to improve clarity.
Reviewed Changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_flake8_async.py | Added "ASYNC125" to the list of error codes to trigger tests. |
| tests/eval_files/async125.py | New test file to validate ASYNC125 behavior for various trio calls. |
| flake8_async/visitors/visitors.py | Updated error messaging to use match.base and refactored error format. |
| flake8_async/visitors/visitor102_120.py | Updated TrioScope constructor usage with explicit parameters. |
| flake8_async/visitors/helpers.py | Refactored get_matching_call to return a MatchingCall dataclass. |
| flake8_async/init.py | Bumped version to reflect recent changes. |
Files not reviewed (3)
- docs/changelog.rst: Language not supported
- docs/rules.rst: Language not supported
- docs/usage.rst: Language not supported
Comments suppressed due to low confidence (2)
flake8_async/visitors/visitors.py:290
- Verify that replacing m[2] with m.base retains the intended error context; if additional details were included with m[2], consider preserving them in the error message.
self.error(node, m.base)
flake8_async/visitors/visitor102_120.py:129
- Ensure that the updated TrioScope constructor signature is compatible with all call sites; if additional parameters become necessary, update the constructor and its callers accordingly.
trio_scope = self.TrioScope(call.node, call.name)
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.
fixes #353
anyio does not currently have
CancelScope(relative_deadline=...), but @agronholm seemed open to adding it so I'm not gonna bother messing around with the error message for now.