Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[flake8-type-checking] Fixes quote_type_expression #14634

Merged

Conversation

Daverball
Copy link
Contributor

@Daverball Daverball commented Nov 27, 2024

Supersedes: #14614
Fixes: #14538
Fixes: #14554

Summary

This achieves a more feature complete version of wrapping annotations in quotes while removing nested forward references and handling nested quotes correctly.

It's not currently making use of the parsed annotations cache. I tried to pass around Checker and ParsedAnnotationsCache, either approach caused a cascade of borrow checker errors related to lifetimes I wasn't able to resolve.

This is not yet trying to force the outermost quotes of the quoted type expression to match our preference, so there are some scenarios where Generator will pick the opposite style.

Test Plan

cargo nextest run

Copy link
Contributor

github-actions bot commented Nov 27, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@Daverball
Copy link
Contributor Author

@MichaReiser This is looking pretty good. Do you want to handle the changes to Generator to allow forcing the quote preference in a separate PR or should I do it as part of this one?

@MichaReiser
Copy link
Member

@MichaReiser This is looking pretty good. Do you want to handle the changes to Generator to allow forcing the quote preference in a separate PR or should I do it as part of this one?

Glad to hear that! I would prefer a separate PR, unless it requires extra work from your side

@Daverball Daverball marked this pull request as ready for review November 27, 2024 14:36
@Daverball Daverball changed the title [flake8-type-checking] Fixes quote_type_expression [flake8-type-checking] Fixes quote_type_expression Nov 27, 2024
@dylwil3 dylwil3 added bug Something isn't working fixes Related to suggested fixes for violations labels Nov 27, 2024
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

This is great

@MichaReiser MichaReiser merged commit 8a7ba5d into astral-sh:main Nov 27, 2024
21 checks passed
@Daverball Daverball deleted the bugfix/quote-annotation-transformer branch November 27, 2024 21:18
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations
Projects
None yet
3 participants