Skip to content

[flake8-type-checking] Fixes quote_type_expression#14634

Merged
MichaReiser merged 4 commits intoastral-sh:mainfrom
Daverball:bugfix/quote-annotation-transformer
Nov 27, 2024
Merged

[flake8-type-checking] Fixes quote_type_expression#14634
MichaReiser merged 4 commits intoastral-sh:mainfrom
Daverball:bugfix/quote-annotation-transformer

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

@github-actions
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Checking file with rule TC006 cause panic TC003’s rewritten annotations have syntax errors and type-checking problems

3 participants