Visitar URL original
[`pyflakes`] Emit semantic syntax errors in string type definitions as `F722` by ntBre · Pull Request #27835 · astral-sh/ruff · GitHub
Skip to content

[pyflakes] Emit semantic syntax errors in string type definitions as F722 - #27835

Merged
ntBre merged 1 commit into
mainfrom
brent/f722-semantic-errors
Aug 18, 2026
Merged

ntBre merged 1 commit into
mainfrom
brent/f722-semantic-errors

Conversation

@ntBre

@ntBre ntBre commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

As uncovered in #17804, F722 previously applied only to parse errors and not to semantic syntax
errors. More confusingly, we were emitting semantic syntax errors, and even other lint rule errors
that correspond to syntax errors, on string type definitions, even when F722 was disabled.

This PR adds a check to Checker::report_semantic_error for the semantic model's
in_string_type_definition flag that converts these semantic errors into regular F722
diagnostics, when the rule is enabled, and returns without reporting an error when the rule is
disabled.

Test Plan

New mdtests covering semantic errors in forward annotations

…s `F722`

Summary
--

As uncovered in #17804, `F722` previously applied only to parse errors and not to semantic syntax
errors. More confusingly, we were emitting semantic syntax errors, and even other lint rule errors
that correspond to syntax errors, on string type definitions, even when `F722` was disabled.

This PR adds a check to `Checker::report_semantic_error` for the semantic model's
`in_string_type_definition` flag that converts these semantic errors into regular `F722`
diagnostics, when the rule is enabled, and returns without reporting an error when the rule is
disabled.

Test Plan
--

New mdtests covering semantic errors in forward annotations
@ntBre ntBre added bug An issue describing something that isn't working, or a PR that fixes a bug rule Implementing or modifying a lint rule labels Aug 18, 2026
@astral-sh-bot

astral-sh-bot Bot commented Aug 18, 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 marked this pull request as ready for review August 18, 2026 17:32
@ntBre
ntBre requested a review from MichaReiser August 18, 2026 17:32
@ntBre
ntBre merged commit b458a04 into main Aug 18, 2026
78 of 79 checks passed
@ntBre
ntBre deleted the brent/f722-semantic-errors branch August 18, 2026 17:38
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 rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants