Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-typingtype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
typing.py contains at least two doctests:
Lines 3377 to 3414 in 81ab0e8
| defis_protocol(tp: type, /) ->bool: | |
| """Return True if the given type is a Protocol. | |
| Example:: | |
| >>> from typing import Protocol, is_protocol | |
| >>> class P(Protocol): | |
| ... def a(self) -> str: ... | |
| ... b: int | |
| >>> is_protocol(P) | |
| True | |
| >>> is_protocol(int) | |
| False | |
| """ | |
| return ( | |
| isinstance(tp, type) | |
| andgetattr(tp, '_is_protocol', False) | |
| andtp!=Protocol | |
| ) | |
| defget_protocol_members(tp: type, /) ->frozenset[str]: | |
| """Return the set of members defined in a Protocol. | |
| Example:: | |
| >>> from typing import Protocol, get_protocol_members | |
| >>> class P(Protocol): | |
| ... def a(self) -> str: ... | |
| ... b: int | |
| >>> get_protocol_members(P) | |
| frozenset({'a', 'b'}) | |
| Raise a TypeError for arguments that are not Protocols. | |
| """ | |
| ifnotis_protocol(tp): | |
| raiseTypeError(f'{tp!r} is not a Protocol') | |
| returnfrozenset(tp.__protocol_attrs__) |
But, they are not ever executed.
I propose to add a DocTestSuite to test_typing to run these tests.
Note, that this is related but not similar to #111682
Linked PRs
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-typingtype-featureA feature request or enhancementA feature request or enhancement