PEP 647 TypeGuard
E884133
PEP 647 TypeGuard is a Python typing feature that allows developers to define user-defined type guard functions, enabling more precise type narrowing and improved static type checking.
All labels observed (1)
| Label | Occurrences |
|---|---|
| PEP 647 TypeGuard canonical | 1 |
How this entity was disambiguated
This entity first appeared as the object of triple T10763916 — resolving that mention is where its identity was fixed. The disambiguator weighed these candidate entities and picked the highlighted one (or “None”, minting a new entity). This is how homonymy is resolved: the same surface form can point to different entities.
Target entity: PEP 647 TypeGuard Context triple: [Python 3.10, hasTypingFeature, PEP 647 TypeGuard]
-
A.
PEP 484
PEP 484 is the Python Enhancement Proposal that introduced a standard for type hints in Python, forming the basis of the language’s static typing ecosystem.
-
B.
PEP 585
PEP 585 is a Python Enhancement Proposal that introduced built-in generic types (like list[int] and dict[str, int]) as a modern replacement for many typing module aliases.
-
C.
PEP 695
PEP 695 is a Python Enhancement Proposal that introduces a new, more concise syntax for type parameter declarations to improve the language’s support for generics and static typing.
-
D.
PEP 636
PEP 636 is a Python Enhancement Proposal that serves as a tutorial-style guide to the structural pattern matching feature introduced in Python 3.10.
-
E.
PEP 634
PEP 634 is the Python Enhancement Proposal that formally specifies the semantics of structural pattern matching introduced in Python 3.10.
- F. None of above. chosen
- G. Unsure - the case is ambiguous/there is not enough information to decide.
Target entity: PEP 647 TypeGuard Target entity description: PEP 647 TypeGuard is a Python typing feature that allows developers to define user-defined type guard functions, enabling more precise type narrowing and improved static type checking.
-
A.
PEP 484
PEP 484 is the Python Enhancement Proposal that introduced a standard for type hints in Python, forming the basis of the language’s static typing ecosystem.
-
B.
PEP 585
PEP 585 is a Python Enhancement Proposal that introduced built-in generic types (like list[int] and dict[str, int]) as a modern replacement for many typing module aliases.
-
C.
PEP 695
PEP 695 is a Python Enhancement Proposal that introduces a new, more concise syntax for type parameter declarations to improve the language’s support for generics and static typing.
-
D.
PEP 636
PEP 636 is a Python Enhancement Proposal that serves as a tutorial-style guide to the structural pattern matching feature introduced in Python 3.10.
-
E.
PEP 634
PEP 634 is the Python Enhancement Proposal that formally specifies the semantics of structural pattern matching introduced in Python 3.10.
- F. None of above. chosen
Statements (47)
| Predicate | Object |
|---|---|
| instanceOf |
PEP
ⓘ
Python typing feature ⓘ |
| affects | type checkers behavior ⓘ |
| backportedFor | Python versions earlier than 3.10 ⓘ |
| backportLocation | typing_extensions.TypeGuard ⓘ |
| belongsTo |
Python type system
ⓘ
Python typing module NERFINISHED ⓘ |
| category | Typing PEP NERFINISHED ⓘ |
| clarifies | how user-defined predicates influence type narrowing ⓘ |
| defines | typing.TypeGuard NERFINISHED ⓘ |
| definesConcept | TypeGuard NERFINISHED ⓘ |
| definesSyntaxElement | TypeGuard[X] return annotation ⓘ |
| designDecision |
TypeGuard is covariant in its type parameter
NERFINISHED
ⓘ
TypeGuard is intended only for return types, not parameters NERFINISHED ⓘ |
| documentationLocation | https://peps.python.org/pep-0647/ ⓘ |
| exampleUse | def is_str_list(val: list[object]) -> TypeGuard[list[str]] ⓘ |
| hasAuthor | Eric Traut NERFINISHED ⓘ |
| hasName | PEP 647: User-Defined Type Guards NERFINISHED ⓘ |
| introducedIn | Python 3.10 NERFINISHED ⓘ |
| language | Python NERFINISHED ⓘ |
| moduleLocation | typing.TypeGuard NERFINISHED ⓘ |
| motivatedBy |
limitations of isinstance-based narrowing
ⓘ
need for reusable predicate functions ⓘ |
| primaryGoal |
enable user-defined type guards
ⓘ
improve static type checking precision ⓘ support more precise type narrowing ⓘ |
| relatedTo |
PEP 484
NERFINISHED
ⓘ
PEP 544 NERFINISHED ⓘ PEP 589 NERFINISHED ⓘ |
| replacesPattern | ad-hoc isinstance checks for complex predicates ⓘ |
| requires | TypeGuard generic parameter to be a subtype of input type ⓘ |
| returnTypeConstraint | TypeGuard must be used as function return type ⓘ |
| runtimeEffect | no direct runtime enforcement ⓘ |
| scope | static type checking only ⓘ |
| semantics |
if function returns True, argument type is narrowed to TypeGuard parameter
ⓘ
type narrowing applies only in True branch ⓘ type narrowing is local to the guarded expression ⓘ |
| status | Accepted ⓘ |
| targetVersion | Python 3.10 NERFINISHED ⓘ |
| usedBy |
Pylance
NERFINISHED
ⓘ
Pyre NERFINISHED ⓘ Pyright NERFINISHED ⓘ mypy NERFINISHED ⓘ static type checkers ⓘ |
| usedFor |
flow-sensitive type analysis
ⓘ
refining union types ⓘ type narrowing ⓘ |
How these facts were elicited
The pipeline generated the facts above by prompting gpt-5.1 with this entity's name + description and the instruction below.
You are a knowledge base construction expert. Given a subject entity and a description of it, return factual statements that you know for the subject as a JSON list of dictionaries(triples), where keys must be "subject", "predicate" and "object". The number of facts may be very high, between 25 to 50 or more, for very popular subjects. For less popular subjects, the number of facts can be very low, like 5 or 10. # Requirements - If you don't know the subject at all, return an empty list. - If the subject is not a named entity, return an empty list. - Include at least one triple where predicate is "instanceOf". - Do not get too wordy. - Separate several objects into multiple triples with one object.
Subject: PEP 647 TypeGuard Description of subject: PEP 647 TypeGuard is a Python typing feature that allows developers to define user-defined type guard functions, enabling more precise type narrowing and improved static type checking.
Referenced by (1)
Full triples — surface form annotated when it differs from this entity's canonical label.