Releases: microsoft/pyright
Releases Β· microsoft/pyright
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.
Published 1.1.376
Bug Fixes:
- Fixed bug that results in a crash when an empty tuple is used to specialize a generic type alias parameterized by a ParamSpec.
- Fixed a bug that results in a false positive reportInconsistentOverload error when the implementation of the overload includes a decorator that changes the type of the implementation to a non-function type.
- Fixed bug that results in a false positive error when type argument for
Literal
doesn't follow type expression rules within a value expression context. - Fixed regression that resulted in a hang when determining whether an overload implementation with generics was compatible with its overloads.
- Fixed bug that results in a false negative
reportIncompatibleMethodOverride
when the child class method uses a type parameter that is scoped to the child class. - Fixed bug that produces signatures with extra (unnecessary) positional-only and keyword-only separators when using a TypedDict with zero fields.
- Improved consistency of parameter name restrictions for the
reportSelfClsParameterName
check. Previously, different rules were applied to__new__
and class methods within metaclasses. - Fixed a false positive error when solving type variables in a call that involves a lambda.
- Fixed bug that results in a confusing type in an error message when
isinstance
type narrowing between atype
and another type creates a subclass. - Fixed bug that leads to false positive error when a protocol has a read-only property a class has a Final variable.
- Fixed bug that leads to a hang under certain circumstances involving deeply-nested higher-order functions.
- Fixed bug that results in a confusing type in an error message when
isinstance
type narrowing between atype
and another type creates a subclass.
Enhancements:
- Enhanced argument-to-parameter matching logic to support dictionary unpacking where the dict key type is a union of literals.
Behavior Changes:
- Changed composition of settings that affect type checking behaviors. Previously, some LSP settings that affect type checking could override config files. Now, the config file always "wins". Command-line parameters passed to the CLI version of pyright win over both LSP settings and config files.
- Changed synthesized comparison methods (
__lt__
, etc.) for dataclasses whenorder=True
to useSelf
rather than an instance of the class. This is not only more consistent with other synthesized methods, but it also preserves covariance of type variables if the dataclass is frozen. - Changed behavior for protocols that have methods with method-scoped type variables. These are no longer treated as free type variables during protocol matching, so they can be used to support rank-2 polymorphism. This behavior is not currently dictated by the typing spec, but it is more consistent with mypy.
Published 1.1.375
Bug Fixes:
- Fixed bug that results in a false positive error when a covariant type variable that is scoped to a method is used in a parameter annotation.
- Fixed bug that leads to internal data structure corruption and subsequent false positive errors in certain cases involving unions of
Unknown
types that include type aliases. - Fixed bug in the
functools.partial
logic that results in incorrect handling of an unpacked TypedDict when used with a**kwargs
parameter. - Fixed bug that results in a false positive
reportUnsupportedDunderAll
warning when using the__all__.extend(x.__all__)
form and the list of entries inx
is empty. - Fixed bug in TypeVar auto-variance calculations for NamedTuples. Since NamedTuple variables are read-only, they should not cause a TypeVar to be invariant.
- Added subtyping support or
IntEnum
andStrEnum
members. These literal values are subtypes of the corresponding literalint
orstr
. - Fixed bug that results in a false positive error under certain circumstances when passing an overloaded function as an argument to a call.
- Fixed bug that caused first argument of
cast
method onmemoryview
object to be treated as a type expression. Pyright was confusing this method withtyping.cast
. - Fixed a bug that results in incorrect overload matching when one overload contains a zero-arity variant and another overload contains an
*args
(variadic) parameter. - Fixed a bug that results in incorrect type narrowing for truthy/falsy type guards consisting of an Enum member when the enum class derives from ReprEnum. In this case, the "magic" of the enum implementation forwards the
__bool__
call to the underlying value. - Fixed a bug that results in incorrect type narrowing when using
isinstance
with an instance of a generic class as the first argument and a concrete subclass as the filter type. - Fixed bug in type narrowing logic for value patterns, specifically when two enums with members of the same name are involved.
- Fixed bug that causes infinite recursion and memory exhaustion under certain circumstances involving recursive type aliases where the type alias is used as a type argument.
Enhancements:
- Updated typeshed stubs to the latest version.
- Added support for
bool
expansion toLiteral[True] | Literal[False]
during pattern matching when using value patterns.
Behavior Changes:
- Changed
disableLanguageServices
feature to apply to hover text as well as other language services. Previously, hover text was excluded. - Allow
Final
andClassVar
to be combined in both directions within a dataclass. Previously, theFinal
qualifier needed to be the outermost.