-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Incorrect scenario of unidiomatic-typecheck #10161 #10170
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fix a false positive for `unidiomatic-typecheck` when comparing two direct types. | ||
|
||
Closes #10161 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,10 +61,22 @@ def deliberate_subclass_check_negatives(b): | |
type(42) is type(b) | ||
type(42) is not type(b) | ||
|
||
def type_of_literals_positives(a): | ||
type(a) is type([]) # [unidiomatic-typecheck] | ||
type(a) is not type([]) # [unidiomatic-typecheck] | ||
type(a) is type({}) # [unidiomatic-typecheck] | ||
type(a) is not type({}) # [unidiomatic-typecheck] | ||
type(a) is type("") # [unidiomatic-typecheck] | ||
type(a) is not type("") # [unidiomatic-typecheck] | ||
def type_of_literals_negatives(a): | ||
type(a) is type([]) | ||
type(a) is not type([]) | ||
type(a) is type({}) | ||
type(a) is not type({}) | ||
type(a) is type("") | ||
type(a) is not type("") | ||
type(a) == type([]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't the issue say that we don't want to suggest this but only exclude the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @zenlyj wanted to treat |
||
type(a) != type([]) | ||
type(a) == type({}) | ||
type(a) != type({}) | ||
type(a) == type("") | ||
type(a) != type("") | ||
|
||
def double_type_check_negatives(a, b): | ||
type(a) == type(b) | ||
type(a) != type(b) | ||
type(a) is type(b) | ||
type(a) is not type(b) | ||
Comment on lines
+78
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of adding a new set of tests here, perhaps we can extend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I would change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with jacob, shall we keep this guard block that checks for literal node types?