Bug Fixes:
- Fixed a bug that results in incorrect type narrowing when a
match
statement uses an empty (zero-element) sequence pattern and the subject expression type is a tuple that potentially (but does not always) have a zero length. - Fixed a crashing bug that results from an internal assertion failure when a generic class that uses PEP 695 syntax is located within an unreachable code block.
- Fixed a bug that results in incorrect type narrowing in the negative (fall-through) case when a
match
statement includes a class pattern with a runtime-checkable protocol class. - Fixed recent regression with the
TypeIs
type guard that resulted in incorrect type narrowing in the negative (else) case. - Fixed a bug that results in incorrect type evaluation for a variable that uses a nonlocal or global binding within an inner scope. Such a variable should never honor the narrowed type from the outer scope.
- Fixed false positive when a TypeVar appears within a function type comment.
- Fixed incorrect type narrowing for a class pattern argument if the class is a generic whose type parameters have default values.
- Fixed recent regression that resulted in incorrect type narrowing when a
*args: P.args
parameter was used in the expressionlen(args) >= x
. - Fixed a bug that resulted in a false negative when a
Literal
with multiple arguments is used in a value expression. It should be treated as aUnionType
special form in this case.
Enhancements:
- Addressed a performance issue when indexing into a value that has a type consisting of a union of many (dozens or hundreds) of tuple types.
- Updated typeshed stubs to the latest version.
Behavior Changes:
- Changed interpretation of function definitions with (*args: Any, **kwargs: Any) to be
...
in compliance with latest typing spec. - Added special-case handling for
__init_subclass__
checks for classes that haveABCMeta
as a metaclass. Previously, these were exempted from__init_subclass__
becauseABCMeta
has a custom__new__
method, but we know that this metaclass calls through totype.__new__
which calls__init_subclass__
.