-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Untested code in typing.py
#105834
Labels
Comments
As has been pointed out in the PR discussion, this code is not in fact dead, just completely untested. (Thanks @JelleZijlstra!) |
AlexWaygood
added a commit
that referenced
this issue
Jun 16, 2023
…#105835) Some parts of the implementation of `typing.Protocol` had poor test coverage
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 16, 2023
…tocols (pythonGH-105835) Some parts of the implementation of `typing.Protocol` had poor test coverage (cherry picked from commit 70c075c) Co-authored-by: Alex Waygood <[email protected]>
AlexWaygood
added a commit
to AlexWaygood/cpython
that referenced
this issue
Jun 16, 2023
…two protocols (python#105835) Some parts of the implementation of `typing.Protocol` had poor test coverage
JelleZijlstra
pushed a commit
that referenced
this issue
Jun 16, 2023
…otocols (GH-105835) (#105859) Some parts of the implementation of `typing.Protocol` had poor test coverage (cherry picked from commit 70c075c) Co-authored-by: Alex Waygood <[email protected]>
JelleZijlstra
pushed a commit
that referenced
this issue
Jun 16, 2023
carljm
added a commit
to carljm/cpython
that referenced
this issue
Jun 16, 2023
* main: pythongh-104799: PEP 695 backward compatibility for ast.unparse (python#105846) pythongh-105834: Add tests for calling `issubclass()` between two protocols (python#105835) CI: Remove docs build from Azure Pipelines (python#105823) pythongh-105844: Consistently use 'minor version' for X.Y versions (python#105851) Fix inaccuracies in "Assorted Topics" section of "Defining Extension Types" tutorial (python#104969) pythongh-105433: Add `pickle` tests for PEP695 (python#105443) bpo-44530: Document the change in MAKE_FUNCTION behavior (python#93189) pythonGH-103124: Multiline statement support for pdb (pythonGH-103125) pythonGH-105588: Add missing error checks to some obj2ast_* converters (pythonGH-105589)
gvanrossum
pushed a commit
to gvanrossum/cpython
that referenced
this issue
Jun 18, 2023
…tocols (python#105835) Some parts of the implementation of `typing.Protocol` had poor test coverage
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug report
If you apply this diff to
typing.py
, all tests continue to pass:The
break
on line 1934 here is unreachable; thus, this whole block of code is pointless:cpython/Lib/typing.py
Lines 1929 to 1934 in 3af2dc7
I think we can say for sure that the
break
here is unreachable. This is the__subclasshook__
method that is monkey-patched onto all subclasses oftyping.Protocol
that do not define their own__subclasshook__
methods. This block of code in the__subclasshook__
method is inspecting the__annotations__
dictionary ofother
to see if it can find any protocol members in that dictionary. But we know that there can't be any protocol members in the__annotations__
dictionary, because if there were, that would makeother
a protocol with at least one non-callable member. If it's a protocol that has at least one non-callable member, the__subclasshook__
method is never called at all duringisinstance()
orissubclass()
checks, because we raiseTypeError
in_ProtocolMeta.__subclasscheck__
, short-circuiting the call toabc.ABCMeta.__subclasscheck__
that would callProtocol.__subclasshook__
:cpython/Lib/typing.py
Lines 1828 to 1831 in 3af2dc7
I believe that this block of code can therefore be safely deleted.
Linked PRs
issubclass()
between two protocols #105835issubclass()
between two protocols (GH-105835) #105859typing.Protocol
(#105835) #105860The text was updated successfully, but these errors were encountered: