-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inference when class and instance match protocol (#18587)
Fixes #14688 The bug resulted from (accidentally) inferring against `Iterable` for both instance and class object. While working on this I noticed there are also couple flaws in direction handling in constrain inference, namely: * A protocol can never ever be a subtype of class object or a `Type[X]` * When matching against callback protocol, subtype check direction must match inference direction I also (conservatively) fix some unrelated issues uncovered by the fix (to avoid fallout): * Callable subtyping with trivial suffixes was broken for positional-only args * Join of `Parameters` could lead to meaningless results in case of incompatible arg kinds * Protocol inference was inconsistent with protocol subtyping w.r.t. metaclasses.
- Loading branch information
1 parent
c8489a2
commit 274af1c
Showing
7 changed files
with
132 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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