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.
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
Add Y062: Protocol method arg should not be pos-or-kw #442
base: main
Are you sure you want to change the base?
Add Y062: Protocol method arg should not be pos-or-kw #442
Changes from 6 commits
97294c7
b9dbfcf
9178dd8
feb136a
5ecbf07
ad2eca4
3e3b2c4
5ca8ceb
4b785ad
4dbc9d3
da93b61
06e5370
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 isn't correct for staticmethods. I think it's questionable anyway to have a staticmethod in a protocol, but there's at least one in the standard library (
email.headerregistry._HeaderParser.value_parser
).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.
if we want to disallow staticmethods in protocols, I feel like that should probably be a dedicated error code -- I lean towards saying check should probably handle staticmethods in protocols in a principled way?
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.
Yes, I should change the code here to handle staticmethods correctly. It's worth thinking about whether we should lint against staticmethods in protocols, but that should be an independent change.
I'm going to hold off on updating this PR for a while though until I can get the typeshed-primer hits down a bit.
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 only allows protocols that use PEP-570 syntax, but typeshed doesn't use any PEP-570 syntax yet.
Also, what if it's a public protocol? In that case, it's probably a stub for a "real" protocol that exists at runtime, so stubtest will start complaining if a parameter is positional-only in the stub but positional-or-keyword at runtime. Maybe we should only complain about private protocols, similar to the way we only complain if a protocol/TypeVar/TypedDict is unused if the protocol/TypeVar/TypedDict is private?
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 fixed the code to also handle
__
(typeshed-primer was unhappy with me about that).Not sure about public protocols; it's probably also a bug in the public code. Let's go over the typeshed hits first to see if there are real-world examples of this problem.