Bug Fixes:
- Fixed a bug in the type narrowing logic for the
S in Dtype guard pattern (where S is a string literal and D is a TypedDict). If the TypedDict is not closed, the absence of the key within the TypedDict definition cannot eliminate the type during narrowing. - Fixed a bug that leads to a false negative when accessing a key on a TypedDict that is defined with
extra_items=Never. - Fixed bug that results in incorrect variance inference when a property access method uses a method-local type variable to annotate the
selfparameter. - Fixed bug that results in a false positive error under certain circumstances where the second argument for a
supercall is a union. - Fixed bug that results in a false negative when deriving from a stdlib protocol class and not implementing one or more abstract methods.
- Fixed bug that results in incorrect type narrowing behavior when the second argument to an
isinstancecall includes a union (specifically with the|operator) within a tuple expression. - Fixed a bug that results in a spurious error when
__class__()is assigned toSelf. - Added missing check for unquoted self references when calling
TypeAliasTypeconstructor manually (as opposed to using the PEP 695typesyntax). - Fixed a bug that results in incorrect expansion of the
bytespromotion type if the value is a bytes literal. - Fixed bug in type narrowing logic for class patterns in a
matchstatement. Negative type narrowing was incorrect when the subject is a literal type and the class is the corresponding non-literal class.
Enhancements:
- Improved handling of
__slots__members to correctly model the case where a descriptor object is stored in a__slots__variable. - Modified
--verifytypesoutput to expand type aliases in its error messages to help diagnose "partially unknown" conditions. - Enhanced
x is ...type narrowing logic to narrowAny | EllipsisTypetoEllipsisTypeto matchx is Nonenarrowing logic. - Updated typeshed stubs to the latest version.
Behavior Changes:
- Switched internal usage of
builtins.function,typing.AwaitableGenerator, andtyping._TypedDicttotypes.FunctionType,_typeshed._type_checker_internals.AwaitableGenerator, and_typeshed._type_checker_internals.TypedDictFallback, respectively.