-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add broken Callable check #5891
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
Conversation
Pull Request Test Coverage Report for Build 1965675033
💛 - Coveralls |
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.
Looks good already!
isinstance(parent_subscript, nodes.Subscript) | ||
and isinstance(parent_subscript.value, (nodes.Name, nodes.Attribute)) | ||
): | ||
return False |
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.
This line is not covered by the tests.
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.
Saw that too. Seems like my previous filter steps are quite good already. Took me a moment to find something that would run this line.
self.add_message( | ||
"deprecated-typing-alias", | ||
node=msg.node, | ||
args=(msg.qname, msg.alias), |
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.
args=(msg.qname, msg.alias), | |
args=(msg.qname, msg.alias), | |
confidence=interfaces.INFERENCE, |
AFAIK because of inferred.qname()
line 275 / 282 ?
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.
Let's do that separately. It would change existing tests.
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.
👌
Type of Changes
Description
Similar to the broken NoReturn check - #5304, however this time for
Callable
.Using
collections.abc.Callable
insideOptional
andUnion
is broken in Python 3.9.0 and 3.9.1.This one is a bit more difficult as we currently currently suggest replacing the deprecated
typing.Callable
withcollections.abc.Callable
. Doing that can result in unexpected errors. The PR will change that behavior and not emitdeprecated-typing-alias
fortyping.Callable
ifpy-version < (3, 9, 2)
. In addition it adds a new check to warn about potential errors.Example broken code
When exactly is it broken?
collections.abc.Callable
as part ofOptional
orUnion
Callable
, e.g.[int]
.https://bugs.python.org/issue42965