PEP 647

E916620

PEP 647 is the Python Enhancement Proposal that introduces "user-defined type guards," enabling more precise static type narrowing in Python code.

All labels observed (1)

Label Occurrences
PEP 647 canonical 1

How this entity was disambiguated

Statements (48)

Predicate Object
instanceOf Python Enhancement Proposal ⓘ
aimsTo enable more precise static type narrowing ⓘ
allows functions to signal refined types to type checkers ⓘ
user code to define custom type-narrowing functions ⓘ
author Jelle Zijlstra ⓘ
Michael Lee ⓘ
belongsTo CPython PEP index ⓘ
linked to: Python PEP index
category Typing ⓘ
clarifies difference between TypeGuard and bool return types ⓘ
interaction of user-defined type guards with union types ⓘ
createdForPythonVersion Python 3.10 ⓘ
definesConstraint TypeGuard may only appear in the return type position of a function ⓘ
TypeGuard return type must be a subtype of bool at runtime ⓘ
definesSyntaxElement TypeGuard return type ⓘ
typing.TypeGuard ⓘ
linked to: TypeGuard
definesTerm user-defined type guard ⓘ
discussesModule typing ⓘ
doesNotAffect runtime semantics of Python programs ⓘ
ensures type guards are only used in positive test positions ⓘ
firstIncludedIn Python 3.10 ⓘ
governsBehaviorOf TypeGuard in typing module ⓘ
linked to: TypeGuard
hasTitle User-Defined Type Guards ⓘ
linked to: TypeGuard
improves precision of conditional type inference ⓘ
introducesConcept user-defined type guards ⓘ
language English ⓘ
modifiesTypingBehavior type checkers ⓘ
motivatedBy limitations of isinstance-based narrowing ⓘ
limitations of literal truthiness checks for narrowing ⓘ
notes TypeGuard is intended for use by static type checkers only ⓘ
linked to: TypeGuard
partOf Python typing ecosystem ⓘ
PEPNumber 647 ⓘ
relatedTo PEP 484 ⓘ
PEP 544 ⓘ
PEP 589 ⓘ
relatesToLanguage Python ⓘ
relatesToTopic static typing ⓘ
type checking ⓘ
type narrowing ⓘ
repository https://peps.python.org/pep-0647/ ⓘ
specifies rules for how type checkers interpret TypeGuard ⓘ
semantics of TypeGuard in conditional statements ⓘ
status Accepted ⓘ
targetsAudience Python developers using static typing ⓘ
library authors ⓘ
type checker implementers ⓘ
useCase custom validation functions that narrow types ⓘ
filtering heterogeneous collections ⓘ
refining Optional types after checks ⓘ

How these facts were elicited

Referenced by (1)

Full triples — surface form annotated when it differs from this entity's canonical label.

Python 3.10 → implementsPEP → PEP 647 ⓘ