Releases: microsoft/pyright
Releases Β· microsoft/pyright
Published 1.1.404
Changes:
- f11dd22 Switch to Node 22 and make publish to npm wait (#10830)
- ba6a729 Update azure-pipelines-release.yml for Azure Pipelines
- 33f41a8 Published 1.1.404
- e32022c Improved performance and memory usage of import resolver by not recording import failure information unless caller asks for it. This is normally needed only when verboseOutput is enabled. (#10819)
- 572bc31 Implemented a number of performance and memory optimizations (#10816)
- 2d1aaf0 Fixed a recent regression that broke the "--threads" option in the CLI. (#10812)
- 7b90e9e Made PEP 728 (TypedDict with extra items) no longer experimental since it has been accepted by the SC. (#10804)
- de2d23d Improved startup performance for large projects by lazily computing the module name of each source file. (#10798)
- 78088b4 Bump tmp from 0.2.3 to 0.2.4 (#10771)
- f1c19c6 Bump axios from 1.10.0 to 1.11.0 (#10742)
See More
- c125807 Bump form-data from 4.0.3 to 4.0.4 in /packages/vscode-pyright (#10732)
- 42c478f Tweaked the new source enumerator implementation so it enumerates files in the same order as the old implementation. The order that files are type checked shouldn't theoretically matter, but in practice there can be minor differences (e.g. union order in error messages).
- b8688e7 Fixed regression that resulted in a false positive error when using
reportUninitializedInstanceVariable
with aNamedTuple
class. This addresses #10490. (#10791) - facb494 Fixed a bug that results in a false positive error when a
break
orcontinue
statement is used within awhile
orfor
loop within an exception group block. This addresses #10766. (#10790) - 6dc4f77 Updated typeshed to the latest version.
- 390f1da Removed trailing whitespace in diagnostic line output. This addresses #10726.
- fd0a5e8 Improved startup responsiveness on large monorepos (#10786) [ #3075 ]
- 8b02aa8 Pull Pylance with Pyright 1.1.403 (#10687)
This list of changes was auto generated.
Published 1.1.403
Enhancements:
- Updated typeshed stubs to the latest version
Behavior Changes:
- Removed experimental support for PEP 736, which was rejected. (#10616)
Published 1.1.402
Changes:
- f584f78 Published 1.1.402
- 0246b06 Fixed bug that results in a false positive "fully overlapping overload" error when a second overload uses a Callable with a ParamSpec but the first does not. This addresses #10587. (#10588)
- ce1c735 Improved modeling of bound and unbound methods so they properly use
types.MethodType
ortypes.FunctionType
. This addresses #10514. (#10586) - 859cc50 Added support for bidirectional type inference when assigning an expression to an unpacked tuple literal and all of the items in the tuple have a declared type. This addresses #10481. (#10585)
- 4887eb7 Fixed bug that results in confusion between two classes defined in the same file with the same name but in different functions when they are used in protocol matching. This addresses #10418. (#10584)
- 4cd01c6 Revert "Added check for mutable values of type list, dict, or set when used as default values for a dataclass field. These result in TypeErrors at runtime. This addresses #10553. (#10557)"
- f326cc6 Added
reportUnreachable
diagnostic check. If enabled, it emits a diagnostic for code that is determined to be structurally unreachable or unreachable via type analysis. It does not report code that is within a code block that is gated by a conditional that is statically determined to be false, such asTYPE_CHECKING
and version checks. This diagnostic check is off by default even in strict mode because there are legitimate reasons for unreachable code to exist in Python code. (#10581) [ #10284 ] - c165c3f Reverted narrowing behavior for discriminating between TypedDicts. This narrowing behavior isn't technically correct from a type safety standpoint, but until PEP 728 is accepted, it's the only practical way to do this form of discrimination. This addresses #10517. (#10579)
- 8610325 Changed behavior when
@final
is applied to a method but subsequent decorators (like@functools.cache
or@property
) subsequently transform the method into a different type. The typing spec is not clear how this should work. Pyright now honors the@final
in these cases, which is consistent with mypy. This addresses #10543. (#10578) - a52db80 Fixed bug that causes bidirectional type inference to be skipped when the target of an assignment is a member access expression (
base.member
) and the base expression is a module. This addresses #10539. (#10577)
See More
- b23d4a2 Fixed bug that results in a false positive
reportUnusedVariable
error under specific conditions when an expression's local type has a circular dependency. This addresses #10512. (#10575) - 6ecb8f2 Added support for Sentinel type introduced in draft PEP 661. The
enableExperimentalFeatures
setting must be set to true to enable this feature. This addresses #10565. (#10574) - db0da4b Added support for Python 3.14 "template string" feature (PEP 750). This addresses #10320. (#10572)
- 6adcbc8 Fixed a bug that results in some additional (unnecessary) memory consumption under certain circumstances involving reachability analysis. This change shouldn't result in any observable behavioral changes other than (theoretically) slightly less memory pressure. (#10569)
- 7137377 Updated typeshed stubs to the latest version.
- 64b389c Fixed bug that results in crash when a class is parameterized by a TypeVarTuple that has a non-TypeVarTuple after it in the type parameter list. This addresses #10563. (#10564)
- 29ce473 Fixed bug that results in incorrect behavior when a type variable is used to define the
extra_items
type for a generic TypedDict. This addresses #10545. (#10563) - 332c215 Added special-case logic to detect when a class-like symbol created by calling NewType is used as an actual class for assignability or member accesses. This addresses #10550. (#10562)
- 0f8ded0 Added support for PEP 758, which allows Python 3.14 and newer to support multiple exceptions in an
except
clause without surrounding parentheses. This addresses #10546. (#10561) - 960fb52 Fixed bug that results in a false negative when attempting to assign an IntEnum or StrEnum literal to the Literal type corresponding to its value type. This addresses #10552. (#10558)
- 9148e3d Added check for mutable values of type list, dict, or set when used as default values for a dataclass field. These result in TypeErrors at runtime. This addresses #10553. (#10557)
- bd84a04 Revert "Fixed bug that results in a false positive when accessing a generic attribute from an object whose type is
type[X]
. This addresses #10304. (#10305)" - 3f17258 Fixed bug in language service code that was mutating the contents of a parse node.
- 743b482 Bump tar-fs from 2.1.2 to 2.1.3 in /packages/vscode-pyright (#10533)
- ced3289 Removed dependency on unused package "leven". No functional change.
- d340ecc Minor code cleanup for consistency and maintainability.
- 9cccf0e Moved regular expressions used in hot paths to global constants so they don't need to be reconstructed each time. (#10506)
- cc812ef Fixed longstanding bug in tokenizer that can result in incorrect behavior under certain circumstances involving characters that require two uint16 unicode character codes (a surrogate followed by a second word). (#10504)
- d296a1a Updated typeshed stubs to the latest version.
- 50dda51 Alternative fix for recent regression related to
_type_checker_internals.pyi
(#10496) - 321b6bf Removed some circular module dependencies. (#10485)
- b249d11 pull-pylance-with-pyright-1.1.401-20250521-185403 (#10486)
This list of changes was auto generated.
Published 1.1.401
Bug Fixes:
- Fixed a bug in the type narrowing logic for the
S in D
type guard pattern (where S is a string literal and D is a TypedDict). If the TypedDict is not closed, the absence of the key within the TypedDict definition cannot eliminate the type during narrowing. - Fixed a bug that leads to a false negative when accessing a key on a TypedDict that is defined with
extra_items=Never
. - Fixed bug that results in incorrect variance inference when a property access method uses a method-local type variable to annotate the
self
parameter. - Fixed bug that results in a false positive error under certain circumstances where the second argument for a
super
call is a union. - Fixed bug that results in a false negative when deriving from a stdlib protocol class and not implementing one or more abstract methods.
- Fixed bug that results in incorrect type narrowing behavior when the second argument to an
isinstance
call includes a union (specifically with the|
operator) within a tuple expression. - Fixed a bug that results in a spurious error when
__class__()
is assigned toSelf
. - Added missing check for unquoted self references when calling
TypeAliasType
constructor manually (as opposed to using the PEP 695type
syntax). - Fixed a bug that results in incorrect expansion of the
bytes
promotion type if the value is a bytes literal. - Fixed bug in type narrowing logic for class patterns in a
match
statement. Negative type narrowing was incorrect when the subject is a literal type and the class is the corresponding non-literal class.
Enhancements:
- Improved handling of
__slots__
members to correctly model the case where a descriptor object is stored in a__slots__
variable. - Modified
--verifytypes
output to expand type aliases in its error messages to help diagnose "partially unknown" conditions. - Enhanced
x is ...
type narrowing logic to narrowAny | EllipsisType
toEllipsisType
to matchx is None
narrowing logic. - Updated typeshed stubs to the latest version.
Behavior Changes:
- Switched internal usage of
builtins.function
,typing.AwaitableGenerator
, andtyping._TypedDict
totypes.FunctionType
,_typeshed._type_checker_internals.AwaitableGenerator
, and_typeshed._type_checker_internals.TypedDictFallback
, respectively.
Published 1.1.400
Bug Fixes:
- Fixed bug that results in a false positive when accessing a generic attribute from an object whose type is
type[X]
. - Fixed bug that results in incorrect type narrowing of a variable that is shadowed in an inner-scoped comprehension.
- Fixed bug that results in a false positive error when referencing a class-scoped type alias defined as a callable.
- Fixed bug that causes bidirectional type inference not to be used in cases where a ternary expression is assigned to an annotated instance or class variable and the ternary condition narrows the type of
self
orcls
. - Fixed bug that results in a spurious "type already specialized" error when using a class-scoped type alias defined using a
type
statement orTypeAliasType
constructor. - Fixed a bug that leads to a hang when a generic type alias definition refers to itself.
- Fixed a bug that results in missing diagnostic details under certain circumstances where bidirectional type inference is attempted in the assignment of an attribute.
- Fixed a bug that results in a false positive error when calling a function with an unpacked TypedDict with
extra_items
when additional keyword args are passed. - [From pylance] Fixed regression introduced in 1.1.399 that caused pyright CLI to fail to run on Linux systems.
Enhancements:
- Extended "type(x) is C" type narrowing logic to support cases where
C
is a union of types or a type variable with a union upper bound. - Added support for PEP 765, which makes it a syntax error (or warning) in Python 3.14 if a
return
,break
orcontinue
is used to exit afinally
clause. - Added check for named tuple field names that begin with an underscore. These result in a runtime exception.
Behavior Change:
- Reverted a recent change that extended the
reportPrivateImportUsage
check to enforce imports from submodules whose names begin with an underscore. This change was disruptive to users of the popularpandas
library because it exports a submodule named_typing
. This was originally intended to be experimental or private, but it was never fully addressed. The pandas maintainers will work to fix this issue (pandas-dev/pandas#55231) over the next year. I'm going to back out this change to pyright in the meantime.
Published 1.1.399
Bug Fixes:
- Fixed bug that results in incorrect type narrowing when a value whose type is a non-callable (and non-final) class is passed as the second argument to an
isinstance
call and the first argument is a callable type. In this case, a subclass could provide a compatible__call__
method, so the type shouldn't be narrowed toNever
. - Fixed bug that results in a false positive "missing stub file" diagnostic when importing a "py.typed" submodule from a namespace package.
- Fixed bug that results in a false negative when a type variable with an upper bound is used to annotate a parameter in a method override.
- Fixed a bug that results in a false negative for a method override that uses
Self
in a contravariant position. - Fixed bug that results in a false positive error under certain circumstances involving a type variable with an upper bound of
type[T]
that is assigned to another type variable. - Fixed a bug that results in a false negative when the specialization of a TypeVarTuple includes multiple unpacked tuples of unknown length.
- Fixed a bug that results in a false negative when a class that derives from
type[Any]
is assigned to any other type. - Fixed bug that results in an incorrect error under certain circumstances when inferring the return type of a recursive function that has a decorator or is
async
. - Fixed bug that results in a false negative when a return statement contains a call expression that invokes a
NoReturn
call and the argument list contains errors. - Fixed bug that leads to a false positive in the
reportUnnecessaryComparison
check when one operand's type is a callable and the other is not. - [From pylance] Fixed a bug that results in an internal assertion (and therefore a crash) when
__builtins__.pyi
imports from a project file.
Enhancements:
- Extended
deprecateTypingAliases
feature to support symbols imported fromtyping_extensions
. - Extended
reportUnknownVariableType
check to include cases where a value whose type is a generic class parameterized byUnknown
is assigned to a variable with a declared type. - Extended the check for
isinstance
andissubclass
argument validation to flag theLiteral
special form, which leads to a runtime error when used in the second argument. - Updated typeshed stubs to the latest version. This version removes support for Python 3.8, which is now out of service.
Behavior Changes:
- Removed support for
ru
andur
string prefixes. These were supported in Python 2.7 but are syntax errors in Python 3.x.
Published 1.1.398
Bug Fixes:
- Fixed bug that results in a spurious type error when a ParamSpec is used in conjunction with a dataclass and a contextmanager.
- Fixed recent regression that results in a false negative when calling a function with a positional-only parameter whose type is generic and has a concrete default argument value.
- Fixed regression that results in an
Unknown
type evaluation where previouslyAny
was generated during bidirectional type inference. - Fixed bug that results in incorrect overload resolution when an unpacked argument is of unknown length and potentially matches multiple overloads.
- Fixed bug that results in a variable being displayed as "not accessed" if it's used in an argument expression for a call expression whose base type is a module or
None
. - Fixed bug that results in a hang under certain very specific circumstances involving a protocol method that has been decorated in such a way that it can no longer be bound to the owning protocol class.
- Fixed a bug that contributes to inconsistent type evaluation results when using the "--threads" feature.
- Fixed bug that results in incorrect "literal math" result when dividing
Literal[0]
by a negative literal int value. - Fixed a bug in "literal math" for shift operators. If the RHS value is negative, the operation is invalid, so literal math shouldn't be applied.
- Fixed bug in "literal math" logic for modulo and floor divide operators that affect cases where operands have different signs.
Behavior Changes:
- Changed algorithm for applying type narrowing upon assignment when one or both of the declared type or assigned type contain "Any".
- Removed special-casing for async functions that skips check for implicit return when the return type is
NoReturn
.
Enhancements:
- Updated typeshed stubs to the latest version.
- Extended
reportPrivateImportUsage
to report the use of symbols imported from private submodules in a "py.typed" or stub library. - Extended the
reportUnnecessaryComparision
check to support the patternsx is None
andx is not None
in cases wherex
is provably disjoint in type. - Added generalized support for assignment expressions (walrus operators) for type guards.
- Extended the type narrowing logic for the
x == L
type guard pattern so it supports the case wherex
isLiteralString
andL
is a string literal.
Published 1.1.397
Bug Fixes:
- [From pylance] Fix problem with partial stub service not being part of Pyright CLI.
- Added additional special-casing to
x in y
type guard logic to handleLiteralString
values. - Partially eliminated inconsistent error reporting when calling a function with a default argument that is not assignable to the declared parameter type. An error will still be reported in the case where the declared parameter type includes an unsolved type variable in most cases, but it will no longer be reported if the unsolved type variable is due to a pseudo-generic class.
- Fixed bug that results in an identifier being marked "unaccessed" if it is used in an argument expression to a call whose type is possibly unbound.
- Fixed bug that leads to a false negative when evaluating a call expression where the callable type is
Any
and an argument expression uses dictionary unpacking but the operands type is not a mapping. - Fixed a bug that results in an incorrect "Unknown" type evaluation under certain circumstances involving an assignment to an annotated variable within a loop.
- Fixed bug that results in incorrect bidirectional type inference when using nested constructor calls for dataclasses.
- Fixed a bug that results in incorrect "literal math" results when using a floor divide
//
operator with literal operands whose signs differ. - Fixed a bug that results in a hang under certain circumstances when inferring the return type of a recursive function.
Enhancements:
- Changed type evaluator to make a best effort to evaluate the return type of a function call even if arguments are missing.
- [From pylance] Implement support for pull diagnostics in pyright.
- Added code to enforce that an argument in a call expression that is unpacked is iterable.
- Improved support for unused import detection for import statements that target multi-part names.
Behavior Changes:
- Changed the type of
__path__
fromIterable[str]
toMutableSequence[str]
. Both are correct, but the latter is more precise. - Improved determinism of
--threads
diagnostic output by always sorting output by file path. - Improved reproducibility of CLI diagnostics in non-threaded case by sorting output by file path.
Published 1.1.396
This is a hot fix release that addresses a regression introduced in 1.1.395 that affected several popular libraries including pandas
.
Bug Fixes:
- Reverted previous bug fix that caused errors to be detected and reported in cases where a library defines a function or method with one or more typed parameters with default arguments whose types are incompatible with the parameter type. Previously, pyright reported these errors in some cases but not in others. The bug fix caused these errors to be consistently reported. However, an unexpected number of libraries are impacted by this change. This reversion will give us time to better understand the extend of the issue and determine the correct long-term solution.
Enhancements:
- Added bidirectional type inference for container types that are parameterized by a protocol that matches a module.
Published 1.1.395
Bug Fixes:
- Fixed a bug that results in noncompliance with the typing spec when a
__new__
method has an explicitAny
return type annotation. In this case, type checkers should assume that the return type of__new__
is not a subtype of the containing class and should therefore ignore the__init__
method. - Fixed bug that results in a spurious "overlapping overload" error if the second both overloads have an
*args
but the first has one or more additional positional parameters - Fixed bug that leads to inconsistent behavior in certain cases involving the evaluation of a call whose target signature involves a parameter with a default argument value, notably where the type of the default value isn't assignable to the declared type of its parameter.
- Fixed a bug that results in a spurious
reportUnknownArgumentType
error under certain circumstances. - Fixed a bug that resulted in a spurious error under certain specific conditions involving a call to a function or method that doesn't have a return type and whose inferred return type is based on variables calculated in a loop.
- Fixed a bug that results in an incorrect error when determining assignability of a function with an
*args
that is unpacked using a*tuple[]
. - Fixed bug that results in a spurious error when an
isinstance
orissubclass
type guard results in a narrowed type that is synthesized as a subclass oftype
and some other class. - Fixed a bug that results in a spurious error when an unpacked iterable argument expression supplies the objects for an
*args
parameter that is annotated with an unpacked TypeVarTuple.
Behavior Changes:
- Exempted
__init__
from override checks even in the case when the override is an object (such as a context manager) rather than a function. - Added special-case logic to permit
type[T]
to be treated as assignable toTypeForm[T]
in accordance with the latest draft of PEP 747. - Changed the interpretation of an async function with an empty body (no yield statement) in a stub file or protocol definition that has a return type annotation of
AsyncGenerator
. Previously, this was assumed to be a generator even though ayield
statement wasn't present. It is now assumed to be aCoroutine
. This behavior is not spelled out in the typing spec, but pyright's new behavior is now consistent with mypy's.
Enhancements:
- Improved error reporting for PEP 728 features when
enableExperimentalFeatures
is not true. - Added error check for member access expressions that attempt to bind an instance or class method to an object or class when the method accepts no "self" or "cls" parameter.
- Added check for invalid creation of
TypeAliasType
outside of a class or module scope. - Updated typeshed stubs to the latest version.
- Added special-case logic to allow
Any
to be defined intyping.pyi
using aclass
statement rather than how it has traditionally been defined.