Bug Fixes:
- Fixed a bug that resulted in a false positive error under certain circumstances involving inferred variance, decorators and generic type aliases.
- Fixed a bug that resulted in a false positive when
Self
was used in a value expression outside of a class body. - Fixed bug that resulted in a false positive error when overriding a TypedDict field when the overridden type was
Any
or vice versa. - Fixed bug that resulted in a false negative when overriding a TypedDict field with an incompatible
Required
orNotRequired
attribute. - Fixed recent regression that resulted in a false negative when
type
ortype[Any]
was used as a type annotation for a field in a dataclass. - Fixed a bug that results in a false positive when
anext
is passed a value of typeAsyncIterator
. - Fixed recent regression that results in false positive error where
type
ortype[Any]
is not considered type compatible withCallable
. - Fixed bug that affected the case where a TypedDict class derived from two incompatible classes using multiple inheritance. The error was reported in the wrong location.
- Fixed bug that results in incorrect type evaluation when a
raise
statement is used within a context manager that swallows exceptions. - Fixed bug that led to incorrect type evaluation with unary operator when used with a type alias defined with forward references.
- Fixed bug that resulted in a crash within the function return type checking logic.
- Fixed bug that resulted in incorrect type evaluation when
del
statement is applied to a class member implemented with a descriptor. - Fixed regression that resulted in a false negative for the
reportUnknownMemberType
check when the expression is a call argument and the member is a function with a partially-unknown signature. - Fixed a bug that resulted in incorrect type evaluation in certain cases involving generic protocols and bound TypeVars.
- Fixed a bug in the code flow engine that resulted in a false negative for a variable whose type is narrowed within an inner loop.
- Fixed bug that led to improper type narrowing for class patterns when
Callable
is used. - Fixed bug that resulted in incorrect narrowed type evaluation in certain circumstances involving certain code flow graph structures.
Enhancements:
- Added support in
dataclass_transform
for custom field specifiers that have default arguments for theirinit
orkw_only
parameters. - Implemented check for inconsistent use of
@staticmethod
and@classmethod
in overloads. - Added support for accessing members of a
TypeAliasType
object. - Added an error check for a PEP 695
type
statement within a function body. Type alias definitions are not allowed within this scope. - Added support for
*args: *Ts
parameter that captures a callable with an indeterminate number of positional parameters because some of them have default arguments. - (Contribution from @jbarrachinab) Improved a few error messages in the Spanish localization.
- Enhanced support for TypeVarTuple capture of a callable to support literal arguments.
- Added a few optimizations that help improve perf somewhat when large unions are involved.
- Added support for doc strings when using the PEP 695
type
statement.
Behavior Changes:
- Added a new typeCheckingMode called "standard". It's a subset of "strict" but a superset of "basic". It is the new default mode, and it should cover all of the required checks for conformance with the Python typing standard.
- Changed behavior of check for unimplemented methods in a class that explicitly derives from a protocol. If the class also explicitly derives from
abc.ABC
, it is exempted from this check. This is useful for mixin classes. - Changed behavior of
reportUnknownMemberType
(and other checks in thereportUnknown...
family) to not report a partially-unknown type if it refers to an unspecialized class. - Moved checks for Required/NotRequired and ReadOnly overrides from reportGeneralTypeIssue to reportIncompatibleVariableOverride for consistency. Added checks for Required/NotRequired and Readonly incompatibilities in the multiple inheritance case.
- Changed behavior of two-argument form of
super
when it is used outside of an attribute access expression. It now employs a heuristic whereby it evaluates to the next base class of the bound type. - Changed the type printer logic to avoid emitting truncated
Literal
string and bytes values when it is asked to enforce Python syntax. This mode is used for inlay hints and the stub generator (for inferred return type comments).