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

False-Positive on TC002, when if TYPE_CHECKING is True: statement is used. #156

Closed
iamibi opened this issue Jul 13, 2023 · 3 comments · Fixed by #157
Closed

False-Positive on TC002, when if TYPE_CHECKING is True: statement is used. #156

iamibi opened this issue Jul 13, 2023 · 3 comments · Fixed by #157

Comments

@iamibi
Copy link
Contributor

iamibi commented Jul 13, 2023

When using a more explicit statement if TYPE_CHECKING is True:, the plugin reports TC002 which is incorrect.
The type checking explicit value to True is a good secure coding practice, specially with a dynamically typed language such as Python.

@sondrelg
Copy link
Member

Thanks for reporting this @iamibi, I definitely understand your motivation. To be honest, I don't think adding the is True adds any value here, but I would be happy to accept contribution which amends the code to add this pattern.

Just so you know, every pattern like this has to be mapped more or less explicitly, so there will always be a need to draw a line in the sand somewhere, in terms of how complex the plugin should be. It isn't a bug, we just haven't added this extra handling yet 👍

@iamibi
Copy link
Contributor Author

iamibi commented Jul 13, 2023

Thanks for reporting this @iamibi, I definitely understand your motivation. To be honest, I don't think adding the is True adds any value here, but I would be happy to accept contribution which amends the code to add this pattern.

Just so you know, every pattern like this has to be mapped more or less explicitly, so there will always be a need to draw a line in the sand somewhere, in terms of how complex the plugin should be. It isn't a bug, we just haven't added this extra handling yet 👍

Makes sense. Will try to add contributions @sondrelg

@sondrelg
Copy link
Member

Let me know if you have questions, I'd be happy to help ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants