Releases: microsoft/pyright
Releases Β· microsoft/pyright
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.
Published 1.1.381
Bug Fixes:
- Fixed bug that results in incorrect type narrowing for sequence patterns in the negative (fall-through) case when the subject is a tuple with an unbounded entry.
- Fixed recent regression that results in a false positive error when attempting to assign the expression
type(Any)
to typetype[Any]
. - Fixed a bug that results in incorrect evaluation of a variable in a doubly-nested loop that is assigned a value in an assignment expression.
- Fixed a bug that results in incorrect narrowing of types for
TypeIs
user-defined type guard in certain cases when variable type is a union. - [Contribution by @dcolascione] Fixed bug that results in a condition where imports stop resolving after file edits that change the set of modules that a file imports.
- Fixed recent regression that results in incorrect type narrowing for
isinstance
in the negative case when usingtype
as a filter. - Fixed bug that results in incorrect reporting of the Python version in a deprecation diagnostic message.
- Fixed bug that results in incorrect code flow involving a call to a
NoReturn
callable with a function decorator applied. - Fixed bug that results in a spurious "symbol refers to itself" error under very specific conditions.
- Fixed bug that can theoretically result in spurious errors when evaluating expressions that involve parameter symbols.
- Fixed bug that results in incorrect type narrowing when
TypeIs
intersectstype[A]
withtype[B]
. Previously, pyright was producing<subclass of type[A] and type[B]>
but now producestype[<subclass of A and B>]
. - [From pylance] Fixed recent regression that caused
venvPath
specified in language server settings to be ignored. - Fixed bug that results in a confusing error message extension referencing a missing
__set__
method when assigning to a class variable that is not a descriptor object. - Fixed a bug that results in a false positive type error and confusing error message when assigning to a class variable that uses
Self
in its type definition. - Fixed a bug that results in spurious "variable not allowed in type expression" errors when a type alias is used in a loop in both a type expression and a value expression.
Behavior Changes:
- Updated provisional support for
TypeForm
based on feedback to draft PEP 747.
Enhancements:
- Expanded
reportUnnecessaryIsinstance
check to report cases where anisinstance
orissubclass
call always evaluates toFalse
. - Improved error message for type violation in assignment statement where the LHS is an instance variable reference.
- [From pylance] Update Unicode range tables to match Unicode 16.0, which is used for Python 3.14.
Published 1.1.380
Bug Fixes:
- Fixed a recent regression that results in incorrect type evaluation when using a two-argument form of
super()
and the second argument istype[Self]
. - Fixed a recent regression that results in a false positive type error when converting certain constructors (such as for the class
defaultdict
) to a callable type. - Fixed recent regression that results in a false positive under certain specific circumstances involving higher-order functions that return generic callable types.
- Fixed a bug that results in a false positive error during protocol matching because writable class variables defined in a named tuple or a frozen dataclass were considered read-only.
- Fixed a bug that causes incorrect type narrowing of expressions used within a tuple expression in the subject expression of a
match
statement. - Fixed a bug that results in an incorrect type evaluation of a higher-order function that is passed an overloaded function.
- Fixed recent regression that results in a false positive error under very specific circumstances involving a function with a TypeVar used in both a contravariant and covariant context and combined by union with other types in the contravariant context.
- Fixed a bug that leads to a false positive "default value is specified as ..." when using
--verifytypes
and the function has a decorator applied that uses a ParamSpec. - Simplified check for unnecessary isinstance call. Removed a bunch of redundant code and fixed a number of bugs in the process.
- Fixed a bug that leads to incorrect type narrowing with
isinstance
orTypeIs
when the filter type (the second argument toisinstance
) is a subclass oftype
. - Fixed bug that results in incorrect type narrowing for the
in
(containment) operator when the filter includes class objects (instances oftype
). - Fixed a bug that results in incorrect type narrowing for the
x is ...
(ellipsis) type guard pattern. - Fixed a bug in the stub generator so it properly outputs type aliases that use the PEP 613
TypeAlias
qualifier. - Fixed bug that causes a crash in the language server under certain circumstances with partially-written code that has syntax errors.
- Fixed a bug that results in incorrect type narrowing for
TypeIs
when it is used with aCallable
type form. - Fixed several inconsistencies and bugs in the
isinstance
type narrowing code involving callables
Enhancements:
- Added performance optimization to better handle the case where a tuple expression contains thousands of entries. This is not typically found in hand-written code, but it can appear in computer-generated code.
- Added support for custom metaclasses that derive from
ABCMeta
. Classes instantiated from such metaclasses are now treated as abstract. - Updated typeshed stubs to the latest version.
Behavior Changes:
- Changed the behavior of the dictionary expansion operator (
**
) when used in an argument expression for a call and the operand is a TypedDict. It now takes into account the fact that a (non-closed) TypedDict can contain additional keys withobject
values. This new behavior is consistent with mypy. - Removed support for python-2 raise statements with comma-delimited operands.
- Changed behavior of raise evaluation logic to allow type of exception to be
Never
. - Changed behavior to allow a value with type
_AnnotatedAlias
to be used with an implicit__getitem__
call even though this type is not documented or declared in typeshed. - Changed stub generator to avoid emitting a
from __future__
import statement, which has no meaning in stub files. - Removed support for custom
callable
type guard pattern. Now that typeshed defines this with aTypeIs
, we no longer require custom logic here.
Published 1.1.379
Bug Fixes:
- Fixed a bug that results in confusing hover information for an attrs field that uses a converter.
- Fixed bug that results in incorrect type evaluation when assigning a recursive type alias to a tuple or list.
- Fixed a bug that can result in difficult-to-reproduce type evaluation errors when modifying code in your editor and using pyright as a language server.
- Fixed bug that results in the incorrect type when the
Callable
special form is used in a value expression.
Enhancements:
- Added check for concatenated bytes and str literals.
- Added provisional support for draft PEP 747 and the
TypeForm
special form. - Updated some diagnostic strings to refer to "type expression" rather than "type annotation" since they apply to some cases that don't involve annotations.
Published 1.1.378
Bug Fixes:
- Fixed bug that results in incorrect logging of the pythonVersion string.
- (from Pylance) Fixed issue that resulted in the incorrect pythonVersion when a pyproject.toml is present with a "[tool.pyright]" section.
- Fixed a bug that results in false negatives for errors in argument expressions used in a call to
functools.partial
in some cases. This same issue also causes symbols accessed in these arg expressions to not be marked as referenced. - Fixed bug that results in a crash in very specific circumstances that involve binding a method parameterized by a function-scoped ParamSpec.
- Fixed a bug that resulted in incorrect evaluation when converting a constructor to a callable and the constructed class has a metaclass with a
__call__
method whosecls
parameter is annotated withtype[T]
. - Fixed bug that results in a
reportIncompatibleMethodOverride
diagnostic being reported in the wrong location in some cases involving decorators. - Fixed a bug that results in a false negative when overloads overlap due to default values.
Behavior Changes:
- Changed the default value of the
disableBytesTypePromotions
setting fromfalse
totrue
. It has been over two years since PEP 688 was accepted, so it's time for us to stop treatingbytes
as an alias forbytes | bytearray | memoryview
. This is a breaking change and may require an update to the pyright configuration for some code bases.
Published 1.1.377
Bug Fixes:
- Fixed bug that results in a crash under certain circumstances when a ParamSpec without a scope is used illegally to specialize a class.
- Fixed a bug that results in a false positive error when assigning a
TypeGuard[T]
orTypeIs[T]
to a supertype ofbool
(likeint
). - Fixed a bug that leads to a crash when
--pythonversion
and--threads
CLI options are used together. - Fixed a bug that leads to incorrect type evaluation in certain specific conditions involving a function decorator with an return type inferred from an inner function parameterized by a ParamSpec.
- Fixed bug that results in a false positive error under very specific conditions involving a recursive type alias that is defined in terms of another type alias.
Enhancements:
- Changed type checking logic to retain a reference to default expressions in function signatures, including synthesized signatures (such as
__init__
methods in dataclasses). This allows the original default value expression to be printed in error messages and language server strings. - Updated typeshed stubs to the latest version.
- Added unreachable code reporting for case statements that are never matched based on type analysis.