Skip to content

[flake8-pyi] Avoid rewriting invalid type expressions in unnecessary-type-union (PYI055)#14660

Merged
AlexWaygood merged 2 commits intoastral-sh:mainfrom
sbrugman:pyi055-exclude-invalid-type-expression
Nov 28, 2024
Merged

[flake8-pyi] Avoid rewriting invalid type expressions in unnecessary-type-union (PYI055)#14660
AlexWaygood merged 2 commits intoastral-sh:mainfrom
sbrugman:pyi055-exclude-invalid-type-expression

Conversation

@sbrugman
Copy link
Contributor

Summary

See this discussion for details #14641 (comment)

Test Plan

Updated the test fixtures to have valid type annotations, and appended the invalid type annotations as check.

// a single parameter. This likely is a confusion with `type[a | b]` or
// `type[Union[a, b]]`. Do not emit a diagnostic for invalid type
// annotations.
if semantic.match_builtin_expr(value, "type") && !matches!(**slice, Expr::Tuple(_))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The user should be notified, but we can leave that for the type checker.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Fab, thank you!

…_union.rs

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@AlexWaygood AlexWaygood added the bug Something isn't working label Nov 28, 2024
@github-actions
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@AlexWaygood AlexWaygood merged commit abb3c6e into astral-sh:main Nov 28, 2024
@sbrugman sbrugman deleted the pyi055-exclude-invalid-type-expression branch November 28, 2024 18:44
@dhruvmanila dhruvmanila changed the title [flake8-pyi] Avoid rewriting invalid type expressions in unnecessary-type-union (PYI055) [flake8-pyi] Avoid rewriting invalid type expressions in unnecessary-type-union (PYI055) Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants