Skip to content

add ASYNC125 constant-absolute-deadline #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2025

Conversation

jakkdl
Copy link
Member

@jakkdl jakkdl commented Apr 2, 2025

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.

@jakkdl jakkdl requested a review from Copilot April 2, 2025 09:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10/10, no notes. Thanks @jakkdl, this will definitely catch some bugs!

@Zac-HD Zac-HD merged commit a719b52 into python-trio:main Apr 2, 2025
11 checks passed
@jakkdl jakkdl deleted the deadline_constant branch April 19, 2025 11:24
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.

New rule: do not pass deadline=<constant> to CancelScope(), move_on_at(), or fail_at()
2 participants