Skip to content

[flake8-type-checking] Never flag annotations in function scopes - #29183

Merged
ntBre merged 3 commits into
astral-sh:mainfrom
Daverball:bugfix/function-scoped-ann-assign-annotation-runtime-semantics
Oct 7, 2026
Merged

ntBre merged 3 commits into
astral-sh:mainfrom
Daverball:bugfix/function-scoped-ann-assign-annotation-runtime-semantics

Conversation

@Daverball

Copy link
Copy Markdown
Contributor

Fixes #29182

Summary

flake8-type-checking.runtime-evaluated-decorators erroneously applied runtime semantics to all annotation assignments inside a function scope. Annotation assignments inside function scopes never result in any actual code for the annotation expressions, they get silently dropped by the compiler and are missing completely from the resulting byte code, so they can never be anything other than typing-only.

Test Plan

cargo nextest run

`flake8-type-checking.runtime-evaluated-decorators` erroneously applied
runtime semantics to all annotation assignments inside a function scope.
Annotation assignments inside function scopes never result in any actual
code for the annotation expressions, they get silently dropped by the
compiler and are missing completely from the resulting byte code, so
they can never be anything other than typing-only.
@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre October 7, 2026 13:15
@Daverball Daverball changed the title [flake8-type-checking] Never flags annotation in function scopes [flake8-type-checking] Never flag annotations in function scopes Oct 7, 2026
@astral-sh-bot

astral-sh-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

βœ… ecosystem check detected no linter changes.

Linter (preview)

βœ… ecosystem check detected no linter changes.

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

@ntBre ntBre added the bug An issue describing something that isn't working, or a PR that fixes a bug label Oct 7, 2026
@ntBre
ntBre enabled auto-merge (squash) October 7, 2026 15:29
@ntBre
ntBre merged commit ba2ddbc into astral-sh:main Oct 7, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime-evaluated-decorators incorrectly applies runtime semantics to annotation assignments in function body

2 participants