Breaking Changes:
Many pyright users have requested finer-grained control over diagnostics — especially for diagnostics that were previously lumped under the catch-all rule reportGeneralTypeIssues
. I was hesitant to do this because it is a breaking change and could be disruptive for some pyright users. However, the time has come to make this change.
The list of new diagnostic rules includes:
- reportAbstractUsage
- reportArgumentType
- reportAssertTypeFailure
- reportAssignmentType
- reportAttributeAccessIssue
- reportCallIssue
- reportInconsistentOverload
- reportIndexIssue
- reportInvalidTypeArguments
- reportInvalidTypeForm
- reportNoOverloadImplementation
- reportOperatorIssue
- reportPossiblyUnboundVariable
- reportRedeclaration
- reportReturnType
- reportUnusedExcept
Refer to the configuration documentation for more details about each of these.
This is a breaking change for code bases that were previously overriding the diagnostic severity for reportGeneralTypeIssues
in the config file, in file-level pyright comments or in # type: ignore
or # pyright: ignore
comments. You will need to update your configuration settings and comments to use the new diagnostic rule names.
Bug Fixes:
- Fixed bug in pyright's "type printer" that resulted in an incorrect output when printing a specialized type alias parameterized by a TypeVarTuple that has a value that contains a tuple with an indeterminate length.
- Fixed a bug that resulted in an incorrect type evaluation when a generator uses an
await
operator within the left-mostfor
. This shouldn't result in anAsyncGenerator
despite what the Python documentation indicates. - Fixed a bug in the
isinstance
type narrowing logic whentype
is filtered using a metaclass instance. - Fixed recent regression that resulted in a crash when using certain language server features with an absolute
extraPaths
value. - Fixed spec conformance issue with TypeVarTuple constraint solving. The spec indicates that if a TypeVarTuple is used multiple times in a callee's signature, the tuple must "match exactly".
- Addressed a bug that led to a false positive (missing error) when a "bare" TypeVar is used as a base class in a class statement.
- Fixed a bug that masked an error (false negative) under certain circumstances when evaluating a lambda.
- Fixed a bug that resulted in a false positive error and incorrect type evaluation when an assignment expression (walrus operator) is used in a comprehension.
- Changed diagnostic rule for the case where
Callable
is missing a second type argument. It should usereportMissingTypeArgument
. - Fixed a bug that led to a false negative when an illegal form of tuple was used:
tuple[*tuple[str], ...]
.
Behavior Changes:
- Changed handling of
tuple[Any, ...]
so it is treated as though it's bidirectionally type compatible with all tuples regardless of length. This change is made in response to a clarification in the typing spec. It brings pyright in alignment with mypy's behavior in this regard.
Enhancements:
- Added check for name mismatch for enum classes defined using the functional syntax.
- Improved handling of custom Enum classes (those that derive from
Enum
or useEnumMeta
). - Added special-case logic for enum classes that are invoked as though they are being constructed.
- Added type enforcement for the
_value_
type in an Enum class. Also added enforcement for custom__new__
and__init__
method signatures. - Improved handling of
Annotated
and other special forms when they are used in runtime value expressions rather than annotations. - Added error reporting for the situation where a generic instance variable is accessed through a class object.
- Updated typeshed stubs to the latest version.