Ignore await and typing ellipsis as non-effectful statements - #22291
Draft
maxfischer2781 wants to merge 7 commits into
Draft
Ignore await and typing ellipsis as non-effectful statements#22291maxfischer2781 wants to merge 7 commits into
maxfischer2781 wants to merge 7 commits into
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.
This PR extends the Python
StatementNoEffectquery to ignoreawaitand typing ellipses expression statements.awaitexpression statements (closes LGTM.com - false positive "Statement has no effect" for Python await #11235)awaitis used to switch between coroutines and execute long-running effects. While strictly speaking anawaitcan have no side-effect, these are so rare that a purely syntactical analysis seems appropriate....as the sole expression statement of a typing stub body (closes False positive – "Statement has no effect" for Python type hint ellipsis #11351)@typing.overloadindicates a function definition purely for its signature, not implementation. An...expression statement is commonly used for the body to denote that the body is insignificant.@typing.overload, aProtocolis only defined for its signatures. An...expression is commonly used for statement bodies.The
Protocolchecl covers indirect subclasses ofProtocolbut currently misses genericProtocols (e.g.class Foo(Protocol[Bar])). The former should already eliminate many false positives, but the latter needs more investigation from my side - I might provide cover this in a later PR if it turns out to be too complicated.