-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't throw away type arguments when matching protocols
Summary: I've been trying to do a typeshed update and ran into a problem with pyre no longer recognizing `TextIO` as matching the `SupportsWrite[str]` protocol. Typeshed recently removed a redundant `def write(self: IO[str], s: str, /) -> int` overload for `typing.IO`, so pyre now needs to recognize that the `def write(self, s: AnyStr, /) -> int` overload allows `TextIO` to match `SupportsWrite[str]` because `TextIO` inherits from `IO[str]`. Where things were going wrong is that pyre was first trying to match `IO` against `SupportsWrite` (throwing away the `str` type argument), picking an overload with `self: IO[bytes]` (because multiple overloads match when considering the bare classes), and concluding that the match failed because `IO[str]` and `IO[bytes]` are contradictory. This change adds a `protocol_arguments` parameter to the `instantiate_protocol_parameters` function in `constraintsSet` so that type arguments are taken into account from the beginning. Reviewed By: stroxler Differential Revision: D64015614 fbshipit-source-id: f91b8ad13cbecc20fd6b1e63e884adb8559774af
- Loading branch information
1 parent
5f2061e
commit ad3e647
Showing
4 changed files
with
106 additions
and
19 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