-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[red-knot] Emit diagnostics for isinstance() and issubclass() calls where a non-runtime-checkable protocol is the second argument #17561
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
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 snapshot honestly feels much too big to me. I only really want to snapshot the new diagnostics for isinstance() and issubclass(); all the reveal_type diagnostics being snapshotted here are pretty noisy. But in order to get a smaller snapshot, I'd have to add another subheading to the protocols.md file, which would break the flow of my literate test suite
|
afb9ea0 to
8906bc9
Compare
cc814e6 to
39e7f80
Compare
8906bc9 to
b4e8e97
Compare
39e7f80 to
a3a208f
Compare
b4e8e97 to
1809727
Compare
a3a208f to
cced1b9
Compare
1809727 to
6aa7491
Compare
cced1b9 to
4b29d91
Compare
carljm
left a comment
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.
Cool!
6aa7491 to
a8fba56
Compare
39538ba to
42c6400
Compare
e96e63f to
7ced9ed
Compare
…ls where a non-runtime-checkable protocol is the second argument
42c6400 to
3db4f2f
Compare
* main: [red-knot] fix collapsing literal and its negation to object (#17605) [red-knot] Add more tests for protocols (#17603) [red-knot] Ban direct instantiations of `Protocol` classes (#17597) [`pyupgrade`] Preserve parenthesis when fixing native literals containing newlines (`UP018`) (#17220) [`airflow`] fix typos (`AIR302`, `AIR312`) (#17574) [red-knot] Special case `@abstractmethod` for function type (#17591) [red-knot] Emit diagnostics for isinstance() and issubclass() calls where a non-runtime-checkable protocol is the second argument (#17561) [red-knot] Infer the members of a protocol class (#17556) [red-knot] Add `FunctionType::to_overloaded` (#17585) [red-knot] Add mdtests for `global` statement (#17563) [syntax-errors] Make duplicate parameter names a semantic error (#17131)
Summary
This PR adds diagnostics for
isinstance()andissubclass()calls where the second argument is a protocol class that is not declared as runtime-checkable. Using @BurntSushi's new diagnostics infrastructure, it makes these diagnostics beautiful too! Here's a screenshot of what they look like in the terminal:Test Plan
Existing mdtests updated, with new snapshots.