Enabled the flake8-type-checking plugin rules for the ruff linter#5029
Open
JayeshHire wants to merge 3 commits intoopen-telemetry:mainfrom
Open
Enabled the flake8-type-checking plugin rules for the ruff linter#5029JayeshHire wants to merge 3 commits intoopen-telemetry:mainfrom
JayeshHire wants to merge 3 commits intoopen-telemetry:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I have enabled the flake8-type-checking plugin rules for ruff linter in this PR. This plugin contains a set of rules which will check for those imports which are only used for type annotations and are not imported inside the type-checking block. Imports which are only used for type annotation are of no use at runtime and they'll just consume unnecessary memory. Hence, they should be imported inside the type-checking block.
TC001-3: Imports used for type annotations should be imported inside the type-checking block
TC004: Imports used at runtime should not be imported inside the type-checking block
TC005: Type checking block should not be empty
TC006: Type expressions in
typing.cast()should be quoted so that they can be ignored at runtimeTC010: Type unions such as
X | Yshould be inside quoted blocks.Ignored rules:
TC007: This rule enforces to add quotes to the data type of
TypeAliasvariables. The static checkers cannot determine the behavior of the runtime typing libraries. This makes this rule unsafe. Hence, ignored here.TC008: This rule is unstable and in preview.
Finally, I have changed all the files which were violating the flake8-type-checking rules.
Contributes to #4227
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: