Skip to content
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

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

Merged

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
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
21 checks passed
@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