Skip to content

[flake8-pyi] Fix false positives on quoted annotations (PYI036) - #29274

Merged
ntBre merged 1 commit into
astral-sh:mainfrom
nekomario28:fix/pyi036-stringized-annotations
Oct 13, 2026
Merged

ntBre merged 1 commit into
astral-sh:mainfrom
nekomario28:fix/pyi036-stringized-annotations

Conversation

@nekomario28

Copy link
Copy Markdown
Contributor

Summary

bad-exit-annotation (PYI036) checked raw annotation expressions, so stringized annotations such as tb: "TracebackType | None" or *args: "object" were flagged even though they mean the same thing to a type checker as the unquoted form.

Each annotation check now goes through Checker::match_maybe_stringized_annotation, covering all three paths in the rule: regular parameters, variadic *args, and @overloaded methods.

Fixes #27755. This follows the approach reviewed in #27758, which was closed unmerged.

Test Plan

  • Extended PYI036.py with stringized object, union, variadic, and overload annotations in both correct and incorrect forms.
  • cargo test -p ruff_linter flake8_pyi: 130 passed.

@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre October 10, 2026 03:41
@astral-sh-bot

astral-sh-bot Bot commented Oct 10, 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 changed the title [flake8-pyi] Fix bad-exit-annotation (PYI036) false positives on stringized annotations [flake8-pyi] Fix false positives on quoted annotations (PYI036) Oct 13, 2026

@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.

Thanks!

@ntBre ntBre added the bug An issue describing something that isn't working, or a PR that fixes a bug label Oct 13, 2026
@ntBre
ntBre merged commit bf70c2d into astral-sh:main Oct 13, 2026
52 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.

PYI036 false positive on stringized (quoted) __exit__ / __aexit__ annotations

2 participants