Releases: microsoft/pyright
Releases Β· microsoft/pyright
Published 1.1.391
Bug Fixes:
- Fixed a bug that results in a crash under certain circumstances when
Self
is errantly specialized. - Fixed bug that leads to incorrect evaluations when a
ClassVar
andFinal
qualifier are both used on the same dataclass attribute. - Fixed bug that leads to a hang when returning a tuple from a lambda argument expression in certain circumstances.
- Fixed bug that results in incorrect evaluation of a generic dataclass entry when the entry is defined by a generic subclass.
- Fixed bug that leads to a false positive error when
--verifytypes
is used and a subclass overrides an attribute that is generic in the base class. - Fixed bug that results in the command-line version of pyright not handling long file lists provided via stdin.
- Fixed bug that results in spurious type evaluation error when an operator overload method like
__add__
is implemented with a descriptor object. - Fixed bug that results in confusing error messages when using
--verifytypes
while targeting a submodule within a package and that submodule is a single-file module. - Fixed recent regression in
isinstance
type narrowing logic that affects the case where the filter type is a metaclass. - Fixed bug that results in order-dependent type errors under certain circumstances involving converter functions in a dataclass.
Enhancements:
- Improved error message for incorrect exception type in an
except
clause. - Added exemption to the
reportUnnecessaryComparison
rule for simple wildcard patterns in acase
clause.
Published 1.1.390
Bug Fixes:
- Fixed recent regression that results in incorrect narrowed type when using the
x in y
pattern wherey
is a container type whose element type isUnknown
orAny
. - Fixed bug that causes a false positive overlapping overload error when the overload accepts a
Callable[..., T]
form. - Fixed a bug that results in a hang under certain circumstances when using a recursive type alias.
- Fixed a bug that leads to a false positive when a function is decorated and has no explicit return type annotation and the body references the decorated function in a loop.
- Fixed a bug that leads to incorrect type evaluation when
__getitem__
is set to a callable object. - Fixed bug that results in confusing error message when there is a partially-unknown metaclass type detected by the
--verifytypes
command.
Enhancements:
- Updated typeshed stubs to the latest version.
- Added check for
\u
and\N
escapes within bytes literals, which are illegal. - Added support for a "bare"
Final
annotation in a dataclass entry that has a default value assigned to it. - Improved dataclass converters to support generic types.
- Added check for importing a
Final
variable from another module and then attempting to overwrite it. - Added check for an attempt to assign to a module-local variable if it is shadowing a
Final
variable declared by the builtins module or some other chained file. - Added support for evaluating the
slice
class type arguments for slice expressions. - Added check for invalid use of
ClassVar
qualifier within aNamedTuple
orTypedDict
attribute annotation.
Behavior Changes:
- Changed inference logic for exception groups to more closely match the runtime. If a non-base exception is targeted, the inferred type is now
ExceptionGroup
rather thanBaseExceptionGroup
.
Published 1.1.389
Bug Fixes:
- Fixed bug that results in a false negative if a
|
union operator creates a union of generic types. These types should be specialized with default type arguments. - Fixed bug that results in false negative when raising a value of type
None
. - Fixed bug that results in an incorrect type evaluation when a
match
statement uses a pattern with a target expression that overwrites the subject expression. - Fixed bug that results in a missing
reportUnknownArgumentType
error if the argument is an expression involving an__init__
parameter in an unannotated (pseudo-generic) class. - Fixed bugs that resulted in false positive errors when using an expression of the form
type(A)
as a base class or a metaclass in a class definition. - Fixed bug that leads to false positive when a method is overridden by a polymorphic method.
- Fixed bug that affects pyproject.toml files with an emoji character by switching to a different toml parser.
- Fixed a bug that results in a false negative when a class is used in a type annotation for a method parameter and both the class and the method are generic and use PEP 695 syntax.
- Fixed a bug that results in a false positive "--verifytypes" error when using an explicit
TypeAliasType
call to create a public symbol in a "py.typed" library. - Fixed bug that results in the incorrect detection of an asymmetric descriptor if the descriptor class is generic.
Enhancements:
- [From Pylance]: Improved signature help to skip keyword-only params with invalid names.
- Added checks for
except*
clause to report invalid usage that is flagged as a syntax error at runtime. - Added check for the illegal use of an
await
keyword in a lambda. - Added missing checks for illegal use of
await
andasync
within list, set and dictionary comprehensions within a non-async function. - Improved a confusing error message that results when a class is assigned to an incompatible class.
- Added narrowing support for a TypedDict value, which can be assumed never to be falsy if it has at least one required entry.
- Improved the "x is y" and "type(x) is y" type guards to better handle the case where
x
is a TypeVar. - Updated typeshed stubs to the latest version.
Published 1.1.388
Bug Fixes:
- Fixed a bug that results in a false positive when a class is defined within a generic function and uses type parameters from that function.
- Fixed a bug that results in unexpected constraint solver results in certain cases involving arguments with lambda expressions.
- Fixed bug that results in false positive under certain circumstances involving classes parameterized with a contravariant type variable.
- Fixed bug that results in incorrect evaluation of class variables assigned in an
__init_subclass__
or__class_getitem__
method. These methods are implicitly class methods even though they are not decorated with@classmethod
. - Removed recent check for illegal identifiers used in
alias
fordataclass_transform
field. This isn't an illegal condition, so the resulting error was a false positive. Instead, changed completion provider to not suggest the illegal identifier as a valid keyword argument.
Enhancements:
- Enhanced the special-case logic for functools.partial so it handles the case where the function has a
**kwargs
parameter typed with an unpacked TypedDict. - Improved the synthesized type of the
keys
,values
anditems
methods on a closed TypedDict to provide a more precise (narrower) type for the key values. - Improved the handling of a TypeVar whose definition involves a circular definition.
- Added check for
__slots__
initialization when the__slots__
list is empty and the class is marked@final
.
Published 1.1.387
Bug Fixes:
- Fixed bug that leads to a false negative when passing multiple
*args
or**kwargs
arguments to a callable parameterized by a ParamSpec. - Fixed issue that results in a false positive "type could not be determined because it refers to itself" error caused by a false dependency due to narrowing logic. This may also improve type analysis performance in some code.
- Switched to a different toml parser to avoid incompatibility with the latest toml standard.
- Changed the evaluated type of an
in
ornot in
operator to bebool
if the LHS doesn't support containment. Previously, the expression evaluated toNever
. - Fixed a bug that results in a false positive when a class parameterized by a TypeVarTuple is used in conjunction with a Self type.
- Fixed bug that results in incorrect type evaluation when performing protocol matching that involves an attribute with a callable type parameterized by a ParamSpec.
- Added protection for an internal call stack overflow when inferring return types in deep call hierarchies within untyped code.
- Fixed a false positive "incompatible method override" error in a case that involves both class-scoped and method-scoped type variables.
- Fix recent regression that broke hover text on
.get()
ofTypedDict
instance. - Fixed a bug that causes a false positive error when a class uses
type(Protocol)
as a base class.
Enhancements:
- Enhanced type narrowing logic for "x == " type guard pattern to handle the case where
x
is a type variable with a literal upper bound or value constraints that are literals. - Improved detection of asymmetric descriptors to handle the case where the
__set__
and__get__
methods are overloaded. - Added experimental support for draft PEP 764: Inlined typed dictionaries.
- Changed check in the pyright VS Code extension for the presence of Pylance. If Pylance is installed in the workspace but is not configured to be loaded (i.e. the "python.languageServer" is set to "None"), then pyright will allow itself to be loaded.
Published 1.1.386
Bug Fixes:
- Fixed issue that results in non-deterministic false positive error, often relating to the "awaitable" check.
- Fixed bug that results in a false positive error when using a traditional generic type alias defined with a "naked" type variable surrounded by
Annotated
within a Python 3.12type
statement. - Fixed a bug that leads to a false positive when using asssert_type with a **kwargs parameter that is annotated with an unpacked TypedDict.
- Fixed recent regression that results in a spurious type error when accessing an instance variable
self.x
ifx
has the type of a class-scoped type variable with a default value. - Fixed a recent regression that results in false positive errors under certain circumstances that involve assignability checks for two callables that involve a
*args: *tuple[]
parameter. - Fixed bug that results in a false positive when resolving a multi-part import target that involves a circular dependency.
- Fixed regression that results in a false positive error (and an error that is reported at a bogus location) when overriding a dataclass field with a converter.
- Fixed bug in constraint solver that resulted in behavior that differed depending on the order of methods in a protocol.
- Fixed a bug that results in a spurious error when specializing an old-style generic type alias whose type is defined as a new-style type alias that has multiple type parameters, only some of which are used in its type definition.
- Fixed bug that leads to incorrect type narrowing in the negative ("else") case when using
isinstance
with a filter type that is typed astype[X]
. - Fixed bug that results in a false negative when the specialization of a ParamSpec results in a signature that has a duplicate parameter name where one parameter has a default value and the other does not.
Enhancements:
- Added a limit to the number of typed declarations that will be evaluated for a single symbol. This mitigates performance issues with code that redeclares a symbol hundreds or thousands of times.
- Updated support for "closed" TypedDict to match latest updates to PEP 728.
- Enhanced the
type(y) == x
type guard logic to support the case wherey
is declared as a type variable with an upper bound that overlaps with the type ofx
. - Updated typeshed stubs to the latest version.
- Updated toml parser library to support toml 1.0.0 syntax.
- Removed the limitation that the "ignore" setting in a config file must be relative to the project root.
Published 1.1.385
Bug Fixes:
- Fixed bug that leads to a false positive error when using
Literal[]
in a value expression (not a type expression) with an unpack operator. - Fixed a recent regression that results in a false positive in cases where a dataclass field has a default value where the expression requires bidirectional type inference for proper type evaluation.
- Fixed recent regression that results in a false negative when calling a constructor for a class with a custom metaclass with a
__call__
method that has an unannotated return type if the arguments passed to the constructor are incorrect. - Fixed bug that results in a false positive when a NamedTuple field uses
...
as a default value in a stub file. - Fixed recent regression that leads to a false positive error when assigning a generic method within a class body.
- Fixed recent regression that results in a false negative when calling a function with an
*args
parameter annotated with an unpackedtuple
. - Fixed bug that results in false positive error when a dataclass field is annotated with a class-scoped type variable and includes a default value whose type require bidirectional type inference.
- Fixed bug that results in incorrect type evaluation and a false negative when accessing an attribute through a TypeVar with an upper bound.
- Fixed bug that results in false positive error regarding a
__bool__
method for a value used in an operand for anor
orand
operator.
Enhancements:
- Added check for
alias
keyword argument in adataclass_transform
field definition call to ensure that it's a valid Python identifier.
Published 1.1.384
Bug Fixes:
- Fixed bug that results in a false positive when
Union
andUnpack
are used outside of a type expression. Normal type expression rules should not be applied in this case. - Fixed bug that results in a false negative under certain circumstances when using PEP 695 syntax and a TypeVarTuple multiple times in a signature.
- Added limiter to sequence pattern matching logic to prevent a combinatoric explosion when performing tuple expansion during narrowing.
- Fixed bug that results in incorrect type narrowing on assignment if the narrowed type is
Self
or another bound type variable. - Fixed a bug that leads to a false negative when a class-scoped variable is annotated with a value-constrained type variable and assigned a default value with one of the value constraints.
- Fixed bug that results in a false positive when using a traditional (non-PEP 695) TypeVar in a type expression and assigning to a
TypeForm
. - Fixed recent regression that caused false positive errors with protocol matching in certain circumstances.
- Fixed bug that leads to a false positive when a callable object uses a
Callable
type annotation for theself
parameter in its own__call__
method. - Fixed a bug that results in the inability to rename a NamedTuple field.
- Fixed a bug that results in incorrect type evaluation when the type of a dataclass field is declared with a type variable but its default value is concrete.
Enhancements:
- Enhanced
isinstance
narrowing logic to retain type arguments in cases where the filter type (the second argument) is a child of the un-narrowed type and the child has a type parameter that is used multiple times in its base class (e.g.Child[T](Parent[T, T])
). - Improved determinism of type evaluations involving unions of literal by taking into consideration literal values when sorting subtypes.
- Updated typeshed stubs to the latest version.
- Added support for
*args: Unpack[T]
whenT
is a type variable with an upper bound of a tuple.
Behavior Changes:
- Removed provisional support for PEP 746 because the PEP has been modified, and there is disagreement about the best approach.
- Changed the default python version from 3.12 to 3.13, now that 3.13 is the latest stable release.
Published 1.1.383
Bug Fixes:
- Fixed a bug that resulted in an incorrect error when using a
# pyright: standard
directive. - Fixed a bug that leads to incorrect type evaluation when "literal math" for unary operators are applied to a TypeVar value that has a literal value upper bound.
- Fixed bug with the provisional
TypeForm
support that breaks aliases ofAnnotated
. - Fixed bug that results in incorrect variance inference for some generic type aliases that use auto variance and nested callable types.
- Fixed bug that resulted in a false negative when assigning a specialized recursive generic type alias to itself when variance of its type parameters are not covariant.
- Fixed several bugs related to the explicit specialization of a generic type alias parameterized by a single ParamSpec.
Concatenate
was being handled incorrectly. - Fixed bug that results in a false negative when a type variable is defined with the expression
...
. This should be flagged as an illegal type expression. - Fixed bug that caused type alias to
Never
orNoReturn
to lose its type alias association in some circumstances.
Enhancements:
- Improved verbose logging of execution environment information.
- Added code to propagate information about certain typing module imports from an implicitly-imported module (e.g.
builtins
or__builtins__.pyi
) soFinal
andClassVar
can be treated as special forms by the binder. This fixes the use of these typing symbols in notebooks within pylance, which leverages implicitly-imported modules to "chain together" notebook cells. - Added check for use of a TypedDict class within a
case
statement class pattern. This condition generates a runtime error. - Improved type evaluation performance in certain cases involving protocol matching for complex, nested protocols.
Published 1.1.382
Bug Fixes:
- Fixed bug that can result in incorrect type evaluation behaviors if a call to
type
is used within a loop. - Fixed bug that results in incorrect type inference for list, set, dict, and tuple expressions that include modules in them.
- Fixed bug that results in false positive error when using a
Final
variable in a protocol and a NamedTuple or frozen dataclass as a concrete class. - Fixed bug that results in a false negative when assigning a value to a union type that includes the same type variable multiple times in at least one invariant context. This change eliminates the concept of a "locked" constraint tracker, which is no longer needed and was the underlying cause of the bug.
- Fixed bug that resulted in a "reportIncompatibleMethodOverride" error being reported in the wrong location when a property method has a decorator applied to it.
- Fixed a bug that results in a false positive when assigning
Never
to a type variable in a contravariant context. - Added check for the illegal use of
TypeForm
as the second argument to anisinstance
orissubclass
call. - Fixed bug that results in incorrect type narrowing when a value typed as
TypeForm
is used as the first argument toisinstance
. - Fixed a bug that can result in a false positive error when a function signature contains a positional-only parameter and a keyword parameter with the same name. This can result from the application of a ParamSpec or through the use of an unpacked TypedDict.
- Fixed a bug that results in incorrect type evaluation behaviors when a class has a custom metaclass with a
__call__
method and a__new__
or__init__
method that provides a different bidirectional type inference context for parameters.
Enhancements:
- Added special-case handling for the
len(t) == L
type guard pattern to handle the negative narrowing case where tuplet
has a minimum length ofL
. In this case, the narrowed type can be computed whereas previously it was left unnarrowed. - Improved hover text for converters in dataclass-like classes.
- Updated typeshed stubs to the latest version.
- Extended
reportUnnecessaryComparison
to cover more cases involvingis
andis not
operators.