Behavior Change: Added new configuration switch disableBytesTypePromotions
that is off by default except in strict mode, when it's on by default. When enabled, it eliminates the old (poorly-documented) behavior whereby bytes
when used in a type annotation automatically implies the union bytes | bytearray | memoryview
. For details, refer to PEP 688. The configuration switch allows code bases to retain the old behavior, but it's likely that the default value of this option will change to true in the future.
Behavior Change: Improved handling of types float
and complex
, which are special-cased in PEP 484 as "promotion types". The new logic now properly models the runtime behavior for isinstance
and class pattern matching when used with these promotion types.
Behavior Change: Added check for the use of an ellipsis for a default argument value for a function that is not in a stub, not overloaded, and without a placeholder implementation.
Bug Fix: Fixed false positive error that occurs when a member of a frozen dataclass is overridden in a subclass. In this case, the type should not be considered invariant because the field isn't mutable.
Bug Fix (from pylance): Fixed recent regression that caused import resolution issues when using UNC paths and symlinks.
Bug Fix: Fixed several issues with logic that performs protocol matching against a module, including a false positive error when matching against a generic protocol.
Bug Fix: Fixed bug in type compatibility checks for LiteralString
. It should not be considered compatible with str
or a specific literal str in an invariant context.
Bug Fix: Fixed a false positive error with the reportUnnecessaryComparison
check when a recursive type alias is used.
Bug Fix: Fixed a bug in the handling of __match_args__
in class pattern matching. Pyright was using the subject's class rather than the pattern's class to look up __match_args__
.
Bug Fix: Fixed a bug in the handling of class pattern matching for subclasses of int
, str
or other stdlib classes that implicitly supply __match_args__
and return self
for matches.
Enhancement: Added a check for class pattern matches where the number of positional patterns exceeds the number of positional fields supported by the class.
Enhancement: Improved error message for type compatibility for list
and dict
types, which enforce invariance. The new error message now suggest the use of Sequence
and Mapping
, respectively.