pyright

Static Type Checker for Python

OTHER License

Downloads
2.3M
Stars
13.2K
Committers
119

Bot releases are visible (Hide)

pyright - Published 1.1.382

Published by bschnurr 25 days ago

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 an isinstance or issubclass call.
  • Fixed bug that results in incorrect type narrowing when a value typed as TypeForm is used as the first argument to isinstance.
  • 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 tuple t has a minimum length of L. 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 involving is and is not operators.
pyright - Published 1.1.381

Published by bschnurr about 1 month ago

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 type type[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 using type 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 intersects type[A] with type[B]. Previously, pyright was producing <subclass of type[A] and type[B]> but now produces type[<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 an isinstance or issubclass call always evaluates to False.
  • 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.
pyright - Published 1.1.380 Latest Release

Published by bschnurr about 1 month ago

Bug Fixes:

  • Fixed a recent regression that results in incorrect type evaluation when using a two-argument form of super() and the second argument is type[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 or TypeIs when the filter type (the second argument to isinstance) is a subclass of type.
  • Fixed bug that results in incorrect type narrowing for the in (containment) operator when the filter includes class objects (instances of type).
  • 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 a Callable 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 with object 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 a TypeIs, we no longer require custom logic here.
pyright - Published 1.1.379

Published by bschnurr about 2 months ago

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.
pyright - Published 1.1.378

Published by github-actions[bot] about 2 months ago

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 whose cls parameter is annotated with type[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 from false to true. It has been over two years since PEP 688 was accepted, so it's time for us to stop treating bytes as an alias for bytes | bytearray | memoryview. This is a breaking change and may require an update to the pyright configuration for some code bases.
pyright - Published 1.1.377

Published by github-actions[bot] about 2 months ago

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] or TypeIs[T] to a supertype of bool (like int).
  • 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.
pyright - Published 1.1.376

Published by github-actions[bot] 2 months ago

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 a type 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 a type 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 when order=True to use Self 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.
pyright - Published 1.1.375

Published by github-actions[bot] 2 months ago

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 in x 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 and StrEnum members. These literal values are subtypes of the corresponding literal int or str.
  • 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 on memoryview object to be treated as a type expression. Pyright was confusing this method with typing.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 to Literal[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 and ClassVar to be combined in both directions within a dataclass. Previously, the Final qualifier needed to be the outermost.
pyright - Published 1.1.374

Published by github-actions[bot] 3 months ago

Note: This week's release includes some major changes related to TypeVar constraint solving that have been in the works for a while. These changes simplify the code, make constraint solving behaviors more consistent, and eliminate a number of false positive errors that were reported over the past year. However, these code changes produce different constraint solving behaviors in some cases. These extensive code changes also come with the potential of regressions. I've done extensive analysis of the type checking outputs across over a hundred public code bases, but it's possible that I've missed something. Please report any new behavior that you think is a bug.

Bug Fixes:

  • Fixed bug in logic that validates subtyping relationships between TypeIs[T], TypeGuard[T] and bool when used in a return type of a callable.
  • Fixed bug that results in a crash if Optional is used with no subscript (i.e. Optional[]).
  • Fixed bug in isinstance type narrowing if the second argument is object and the first argument is a type instance.
  • Fixed a bug that results in a crash in certain conditions involving a corrupt builtins.pyi stub.
  • Fixed recent regression that results in incorrect isinstance type narrowing when the filter class and the type are both protocols.
  • Fixed bug that results in a warning if the self parameter in an __init__ method is given an explicit Self annotation.
  • Fixed recent regression that results in a false positive error when evaluating certain nested constructor calls when used with bidirectional type inference.
  • Fixed false positive error when iterator returns a class object from its __iter__ method.
  • Fixed recent regression that results in a false positive error under certain circumstances when yield expression includes a call to a constructor.
  • Fixed a bug that results in an incorrect "inconsistent overload" error when the overloads return TypeIs or TypeGuard and the implementation returns bool.
  • Fixed a bug that results in incorrect type narrowing when tuples are used in conjunction with TypeIs.
  • Fixed a bug that can result in incorrect type evaluation when an isinstance type narrowing results in an intersection type.
  • Fixed bug that results in a false negative if a __set__ descriptor method is marked deprecated and is implicitly accessed using an augmented assignment operator, as in a.x += 1.
  • Fixed bug that can result in a false negative when a function return type is a TypeVar and the function falls through and implicitly returns a None.
  • Fixed bug that can result in a false positive when calling the constructor within a class that has unannotated __init__ or __new__ method parameters.
  • Fixed bug that results in false positive error under certain circumstances when solving type variables that involve literal values.
  • Fixed bug that results in a false positive when using a two-argument form of super() outside of a class.

Enhancements:

  • Improved signature help for constructor calls. Replaced old heuristics that displayed either the __init__ or __new__ signature with a mechanism that uses the recently-ratified typing spec algorithm for converting a constructor into a callable. This is prompted in part by this discussion.
  • Added error check for an enum attribute with a "naked" Final attribute. This should be considered invalid.
  • Added a new configuration option enableReachabilityAnalysis. It is off by default when typeCheckingMode is "off" but otherwise on by default. When disabled, it causes pyright not to identify code blocks that are determined to be unreachable via type analysis. Code blocks that are determined to be unreachable via non-type information are still displayed as such.
  • Enhanced type narrowing for sequence patterns to support tuple expansion when the subject is a tuple whose entries are union types.
  • Added missing check for Final variable assigned in a loop.
  • Added support for @deprecated decorator on magic methods for unary and binary operations.
  • Added support for @deprecated on __bool__ magic method used by not operator.
  • Added support for @deprecated on __new__ methods used implicitly during a class constructor call.

Other Changes:

  • Changed evaluation behavior for TypeVar bounds, constraints, and defaults to enforce type expression evaluation rules, consistent with the typing spec.
  • Eliminated error condition when using a subscript expression for a generic class that does not conform to type expression rules (e.g. list[1 + 2]) if the expression is a value expression.
  • Modified heuristics in T is None type narrowing logic to handle TypeVars with no bounds better. The previous logic was arguably correct, but it produced results that were unexpected by some users.
  • Adjusted the heuristics for constraint solving to favor solutions of type T over type[T]` when both are valid.
pyright - Published 1.1.373

Published by github-actions[bot] 3 months ago

Bug Fixes:

  • Fixed regression that results in a false positive when an Annotated type is used in a type argument within a specialized type on the LHS of a call expression, such as list[Annotated[int, ""]]().
  • Fixed a bug that results in incorrect type evaluation in certain edge cases involving bidirectional type inference with TypeVarTuples.
  • Fixed a bug that results in a false positive error when using bidirectional type inference for a call expression where the expected type is a union.
  • Added the distinction between "external" versus "internal" type variable scopes. This is important for generic class implementations that call their own constructors.
  • Fixed a bug that results in incorrect type narrowing when using TypeIs form when the return type of the type guard function is a specialized generic class.
  • Fixed bug that results in a false positive "overlapping overload" diagnostic when the later overload includes a callback function with a TypeVar in a parameter type.
  • Fixed bug that resulted in an infinite loop when evaluating a call that passes the same call as an argument. Simplified tracking of unique signatures within the code.
  • Fixed a bug that can cause a hang during type analysis for complex code with loops. There are rare circumstances that can cause types not to converge due to symbol dependencies and unstable overload resolution. This change adds a hard limit on the number of attempts to converge types in a loop before giving up.
  • Fixed a bug that results in false negatives in certain cases involving bidirectional type inference for constructor calls.
  • Fixed issues with the reportInconsistentConstructor. It produced false negatives in some cases and produced bad error messages in other cases.
  • Fixed bug that results in a crash if an explicit specialization of a class parameterized by a ParamSpec has zero type arguments. This is a syntax error, but it shouldn't cause the type evaluator to crash.

Behavior Changes:

  • Changed all diagnostic generated in the type evaluator to have a diagnostic rule associated with them so their severity is under user control.
  • Changed internal behavior to retain type alias information when applying solved type variables for a type. This doesn't change type checking behaviors, but it changes language server output (e.g. hover text) in some cases. It can also affect diagnostic messages.

Enhancements:

  • Added provisional support for draft PEP 736 (keyword argument shortcut syntax).
  • Added check for class attribute type declarations that use method-bound type variables. These should be illegal.
  • Improved type evaluation for tuples index expressions with negative subscripts and an entry with an indeterminate length.
  • Made support for "converter" parameter in dataclass_transform fields non-experimental. This functionality has been approved by the typing council.
  • Added support for bidirectional type inference for __extra_types__ in a closed TypedDict.
  • Updated typeshed stubs to the latest version.
  • Added support for auto-synthesized __replace__ method in dataclass and namedtuple classes, a new feature in Python 3.13.
pyright - Published 1.1.372

Published by github-actions[bot] 3 months ago

Bug Fixes:

  • Fixed bug that can result in incorrect evaluation of a traditional (pre-PEP 695) type alias the defines a union which is later used as the second argument to an isinstance or issubclass call.
  • Fixed bug in type narrowing logic for sequence pattern matching when a "star" entry in the pattern captures a TypeVarTuple. The resulting type should be Unknown rather than the unpacked TypeVarTuple.
  • (from pylance) Fixed regression that broke CLI when used with poetry or other tools that depend on the working directory.
  • Fixed a recent regression that results in a false positive when the fully-qualified form of typing.Request is used in an annotation expression.
  • Fixed a bug that results in false positive reportInconsistentConstructor errors if one or both of __init__ or __new__ are overloaded.
  • Fixed a bug that results in a false positive reportOverlappingOverload error in certain cases involving ParamSpec and Concatenate.
  • Fixed a bug that results in incorrect import resolution behaviors when a ".py" file and a directory have the same name, and the directory doesn't have a __init__.py file in it. In this case, the ".py" file should take precedence during imports.
  • Fixed inconsistent behavior when evaluating a binary expression with an or or and operator when the LHS evaluates to a literal int, str, bytes or bool type.
  • Fixed bug that results in a false positive error under certain circumstances when a generator function with no type annotation contains a return value.
  • Fixed bug that results in some circumstances in incorrect specialization of type[T] when T evaluates to Any.
  • Fixed false positive error when using an overloaded __init_subclass__ method under certain circumstances.

Enhancements:

  • Added support for negative type narrowing (in the fall-through case) for a mapping pattern consisting of a single dictionary expand entry. This should match all mapping types, eliminating them in the fall-through case.
  • Added support for class declarations within an enum class body -- both with and without @member and @nonmember decorators.
  • Added "literal math" support for bitwise operators (left shift, right shift, logical or, logical and, logical xor, and invert).
  • Improved the handling of bidirectional type inference for call expressions when the expected type comprises a union.
  • Added "literal math" support for exponentiation operator.
  • Improved performance of type analyzer an average of 12% by refactoring internal data structures and making key objects "monomorphic". This allows the V8 Javascript engine (used in node) to JIT more optimal code.

Behavior Changes:

  • Changed union creation logic to retain (rather than elide) redundant literals in some cases. In particular, for type expressions that explicitly include literals along with their non-literal counterpart like Literal[1] | int. Retaining these redundant subtypes can be useful for language server features like completion suggestions.
  • Changed the type of the __doc__ attribute for a module to always be str | None. Previously, pyright changed its declared type to str if a docstring was present in the module, but this is incorrect because it's a writable value and can be set to None.
  • Changed logic for explicit specialization to allow Never as a type argument for a value-constrained type parameter if Never is an explicit constraint.
pyright - Published 1.1.371

Published by github-actions[bot] 3 months ago

Bug Fixes:

  • Fixed regression that results in a false positive when a traditional type alias (not using PEP 695 syntax) defines a union and is then used as a second argument to an isinstance or issubclass call.
  • Fixed bug that results in a false positive error when an unpack operator is used in an unparenthesized tuple expression on the RHS of an augmented assignment operator on Python 3.9 and newer.
  • Fixed bug that results in a false positive error when using a TypeVar with an upper bound of type as a base class in a class statement.
  • Fixed bug that results in false negative when a list or set expression includes more than 64 elements and is being evaluated with a bidirectional inference context.
  • Fixed type evaluation of old-style (pre-PEP 695) type alias that aliases a generic class when it is used as a direct constructor call.
  • Fixed bug that causes a false positive error when an __init_subclass__ has overloads.
  • Bumped minimum engine version from 1.86 to 1.89 to match the recently-updated language client library requirements.

Behavior Changes:

  • Changed the hard-coded type of the __class__ symbol to be Self@T rather than T (where T is the enclosing class).

Enhancements:

  • Added experimental support for multithreaded type checking in CLI. You can now specify --threads followed by an optional thread count. If no count is specified, pyright will use a value equal to the number of logical processors. Experimentation shows that this can speed up type checking by 2x to 3x for larger code bases. It has little or no effect (and possibly negative effects) for small code bases.
  • Improved detection of the use of variables used in type annotations.
  • Improved type narrowing in the fall-through case for sequence patterns when the pattern includes a star pattern and the subject type is a tuple with an indeterminate entry.
  • Improved handling of tuple expressions used in type expressions that involve specialization, such as dict[()].
  • Updated typeshed stubs to the latest version.
  • (From pylance) Improved security of python interpreter execution when determining the default python import resolution paths and python version.
pyright - Published 1.1.370

Published by github-actions[bot] 4 months ago

Bug Fixes:

  • Fixed bug that resulted in a false negative when assigning to type tuple[Never].
  • Fixed bug that results in incorrect type isinstance or issubclass type narrowing when using a type variable with an upper bound that includes a promotion type.
  • Fixed recent regression that results in an assertion failure (and therefore a crash) when type() is called with dynamic base classes.
  • Fixed bug that results in a false positive when a protocol includes a method implementation that conditionally raises NotImplementedError.
  • Fixed bug that results in false positive reportInconsistentOverload and reportNoOverloadImplementation errors when an overloaded decorator is applied to a non-overloaded function or method.
  • Fixed recent regression that results in false positive when a inner function with an inferred return type is a coroutine (async) and is referenced within the function body in which it's declared.
  • (from Pylance) Fixed recent regression that results in diagnosticSeverityOverrides to be ignored if a pyproject.toml file is present, even if there is no [tools.pyright] section in it.
  • Fixed bug that results in incorrect type evaluation of a function that accepts a Callable[P, T] and is passed a class object whose constructor needs to be converted to a callable.
  • Fixed bug that results in a spurious error when evaluating a quoted (forward reference) type expression that includes an index expression within a TypeAlias definition.
  • Fixed a bug in the type narrowing for the "x is " type guard pattern when <class> is a specific class T, as opposed to a variable of type type[T].
  • Fixed bug that resulted in a false positive error when an abstract class is used for a NewType and the new type is constructed.
  • Fixed bug that results in the incorrect default value of a variadic type variable when the type argument is not provided. It should default to *tuple[Any, ...], not *tuple[Any].
  • Fixed bug that results in a false negative when passing an extra keyword argument to a callable that is parameterized with a ParamSpec.
  • Fixed bug that results in a false positive reportUntypedFunctionDecorator error under certain circumstances.

Enhancements:

  • Updated typeshed stubs to the latest version.
  • Improved analysis performance for complex code flow graphs by adding a cache for reachability.
  • Implemented optimization in the protocol matching cache.
  • Improved handling of special forms, including TypeAliasType instances, when used in value expressions.
pyright - Published 1.1.369

Published by github-actions[bot] 4 months ago

Behavior Changes:

  • Improved consistency of unreachable code. Previously, unreachable code was not supported for if or else suites when the condition type was narrowed to Never.
  • Changed hover provider output for type aliases to conform more closely with the new Python 3.12 type syntax.

Enhancements:

  • Added support for detecting mismatched property types in base classes used for multiple inheritance.
  • Improved reportUninitializedInstanceVariable check to handle dataclass variables that are initialized implicitly by the synthesized __init__ method.
  • Added support for walrus (assignment) operator within set literal expressions if the python version is >= 3.10. The grammar was changed in 3.10 to support this.

Bug Fixes:

  • Fixed recent regression in reportUninitializedInstanceVariable check relating to NamedTuple instance variables.
  • Fixed bug that leads to a false negative when a subscript object used in an index expression supports __index__ but the indexed object specifies that it requires int.
  • Fixed recent regression that results in a runtime assert (and therefore a crash) in certain circumstances when computing the MRO for a class.
  • Fixed bug that results in an incorrect overload implementation diagnostic when using tuple[()] in overloads.
  • Improved diagnostic messages for type errors detected during __set__ and __delete__ calls to a descriptor object.
  • Fixed bug that results in a false positive error when using a callback protocol with a function-scoped type variable.
  • Fixed bug that incorrectly evaluates a constructor call to a constructor that infers a class-scoped ParamSpec when the passed function is generic.
  • Fixed bug that leads to a spurious "unbound variable" diagnostic when a variable is assigned a value using a walrus operator and is later used in a ** call argument.
  • Fixed bug that results in incorrect type narrowing in the negative (fall-through) case of a match expression when the subject expression is an unbounded tuple.
pyright - Published 1.1.368

Published by github-actions[bot] 4 months ago

Bug Fixes:

  • Fixed a bug that causes warnings.deprecated not to work if the python version is 3.13. This was caused by recent changes to typeshed stubs.
  • Fixed bug that results in inconsistent diagnostics when surrounding an argument expression with parentheses.
  • Fixed bug that causes a "bare" type (with no type argument) or type[Any] to be treated as a possible descriptor object.
  • Fixed regression that results in an internal assertion (and crash) related to TypeVar variance inference.
  • Fixed a bug in the "type printer" (the component responsible for translating a type into its textual form) for type aliases defined using PEP 695 syntax.
  • Fixed bug that resulted in the incorrect synthesis of __dataclass_fields__ for named tuples.
  • (Contributed by @InSync) Fixed stubPath's default value in configuration schema.
  • Fixed bug in pattern matching for Callable() in the negative (fall-through) case.
  • Fixed bug that results in unions consisting of different specialized forms of a generic TypedDict to "lose" all but one of these subtypes.

Behavior Changes:

  • Changed inference behavior for generator functions with no reachable yield or yield from statements. The "yield type" (the first type argument to Generator) is now inferred as Never in this case rather than None.
  • Changed the behavior of double underscored symbols that are part of a module's namespace when that module is not a stub or in a "py.typed" package. Such symbols are no longer ignored, although they are considered private.
  • Changed the way that PEP 695 type aliases are displayed when hovering over a reference to the type alias. Previously, the symbol was displayed as TypeAliasType rather than the expanded type alias type.

Enhancements:

  • Added support for deprecated objects that are instantiated prior to being used as a decorator. This allows for a factory usage pattern.
  • Added check for illegal use of Protocol type argument that is not a type parameter. The runtime generates an exception for this condition.
pyright - Published 1.1.367

Published by github-actions[bot] 4 months ago

Bug Fixes:

  • Fixed bug that results in incorrect truthy/falsy type narrowing for an enum that overrides __bool__.
  • Fixed bug that results in a false positive when accessing a generic attribute in a base class from a subclass that explicitly specializes the generic type.
  • Fixed bug that results in duplicate and (contradictory) diagnostic outputs in certain cases where reveal_type is used in a loop.
  • Fixed a bug that results in incorrect (local) type evaluation of an instance variable with a declared type when assigned within a loop that uses an augmented assignment.
  • Fixed bug that causes Final annotation not to be honored when wrapped in an Annotated annotation.
  • Fixed bug that results in a false positive error under certain circumstances involving tuple type narrowing in a loop.
  • Fixed bug that led to divergent behaviors between pyrightconfig.json and pyproject.toml configurations. Specifically, default exclude patterns were not added in the case of pyproject.toml. Thanks to @augustelalande for contributing to this fix.
  • Fixed bug that results in parameter types being converted to Any when converting a NewType or dataclass constructor to a callable.

Enhancements:

  • Updated typeshed stubs to the latest version.
  • Implemented provisional support for PEP 746, which provides consistency checks for metadata used in an Annotated annotation.
  • Added check for except* to enforce that exception class does not derive from BaseExceptionGroup.
  • Added the ability to override type checking configuration settings for each execution environment. This allows, for example, a test directory to use different settings than the directories that contain production code.

Behavior Changes:

  • Added extra blank line to JSON output to assist with parsing when used in watch mode.
  • Changed the import resolution order to better reflect runtime behavior and match a proposed change to the typing spec. In particular, stdlib typeshed stubs are now resolved prior to site_packages.
pyright - Published 1.1.366

Published by github-actions[bot] 5 months ago

Bug Fixes:

  • Fixed bug that results in a false positive error under certain circumstances involving a call to a higher-order generic function with another function that involves a class with a contravariant type variable.
  • Fixed bug that results in a confusing error message when stub generation fails.
  • Fixed bug that results in false positive when evaluating the call to a generic function that involves a type variable used in both a covariant and contravariant (or invariant) position and both literal and non-literal types are involved.
  • Fixed bug that results in a false negative when solving a type variable that involves an invariant context.
  • Fixed a bug that can result in incorrect type inference for a subexpression that is part of an assignment expression if executed with an inference context (bidirectional type inference).
  • Fixed bug in x is E type narrowing pattern where E is an enum literal and x is a supertype of E like object.

Behavior Changes:

  • Changed behavior of constructor call evaluation when __new__ evaluation results in type evaluation errors. Previously, pyright skipped the __init__ evaluation in this case. It now proceeds to evaluate __init__, potentially generating redundant errors.
  • Removed support for inlined TypedDict annotations. This was an experimental feature that never gained enough support to make it into a PEP.
  • Changed behavior of pyright to match the latest typing spec when it encounters an attribute with a type annotation within an Enum class body in a stub. These are now treated as non-member attributes rather than members. Typeshed stubs have been updated to conform to the new standard.
  • Added diagnostic check for an enum member with a type annotation. The typing spec says that this should be considered a typing error.

Enhancements:

  • Updated typeshed stubs to the latest version.
pyright - Published 1.1.365

Published by github-actions[bot] 5 months ago

Bug Fixes:

  • Fixed regression that results in the incorrect type evaluation for the value attribute of a StrEnum or IntEnum class.
  • Fixed a bug that results in incorrect type compatibility checks for a callable that uses *args: *tuple[T, *tuple[S, ...]].
  • Fixed a bug that results in an unsolved TypeVar when calling list(tuple()).
  • Fixed bug that leads to inconsistent narrowing-on-assignment behavior when a tuple instance with unknown type arguments is assigned to a target symbol with a declared tuple type.
  • Fixed bug that results in a false negative when a Final class variable is assigned a value in the class body and reassigned a value in the __init__ method.

Behavior Changes:

  • Changed tuple expression inference behavior to not preserve literal entry types if the tuple expression is embedded within another tuple, set, list, or dictionary expression.
  • [Contribution by @ujan-r] Use typeshed version info for stdlib module list.

Enhancements:

  • Improved diagnostic messages for parameter mismatch.
  • Added support for configuration inheritance through an "extends" configuration option.
  • Added support for custom ".toml" files specified via the -p option on the command line.
pyright - Published 1.1.364

Published by github-actions[bot] 5 months ago

Bug Fixes:

  • Fixed bug that results in a false negative syntax error when a PEP-695 type alias uses a keyword as a name.
  • Fixed a bug that leads to a false positive error when first argument to super call is an instance of a metaclass.
  • Fixed recent regression that results in a false positive when accessing an enum member from an instance of an enum class.
  • Fixed bug that results in a false negative when determining if a callable type is compatible with another callable type and the first has a *args parameter and the second has a single positional+keyword parameter.
  • Fixed a bug in the code flow engine that results in incorrect type evaluation in certain cases involving codependent variables in a loop.
  • Fixed a bug that results in incorrect type narrowing for a type guard function that uses TypeIs[type[T]].
  • Fixed regression related to "converter" field parameter for dataclasses when the converter refers to a generic class constructor.
  • Fixed a bug that results in a false negative when a generic function has a parameter with a generic type and a default argument value. This could lead to a typing hole when considering subtyping rules for callables.
  • Fixed a bug in the dataclass "converter" support that resulted in an error if the converter is tuple.
  • Fixed regression that results in incorrect type evaluation for annotations that involve nested protocols (such as P[P[T]]).
  • Fixed a bug that resulted in an infinite loop when a function that uses an *args: *Ts parameter is passed as an argument to itself.
  • Fixed bug that leads to a false negative when calling a callback function that returns a callable with a generic parameter type.

Behavior Changes:

  • Changed the handling of Enum subclasses that explicitly override value or name to avoid using the special-case logic for computing these types. This is done regardless of whether the class uses a custom metaclass.
  • Changed support for dataclass "converter" field parameter to be off by default. The "enableExperimentalFeatures" must now be enabled to use this feature. If and when PEP 712 is approved, it will be moved out of experimental.
  • Added support for using Literal and various other special forms in a value expression.

Enhancements:

  • Added support for recent addendum to typing spec that provides a special case for dataclasses so ClassVar and Final can be used together to distinguish between a regular Final instance variable and a ClassVar that is also Final.
  • Updated typeshed stubs to the latest version.
  • Improved type printer (the component that converts an internal type to textual format for diagnostic messages) so it better handles special forms like Literal or unions when used in a value expression.
pyright - Published 1.1.363

Published by github-actions[bot] 5 months ago

Bug Fixes:

  • Updated manifest to reflect the correct default value for reportInvalidTypeForm.
  • Fixed bug that resulted in diagnostics associated with the reportUnnecessaryTypeIgnoreComment check to not include the error code.
  • Fixed bug that causes a false positive reportPrivateUsage error when a global or nonlocal binding is used within a class to access an outer-scoped variable.
  • Fixed bug that results in a false positive reportUnnecessaryComparison when a variable is used in a conditional expression and its type is a union that includes a Coroutine and a non-coroutine.
  • Fixed false positive deprecatedTypingAliases deprecation for collections.abc.AbstractSet due to a recent change in typeshed stubs.
  • Fixed recent regression that results in assert_type failure when a class is parameterized by a ParamSpec with a default value.
  • Improved handling of constrained TypeVars when used with unary operators.
  • Fixed bug that results in incorrect type narrowing for a tuple with determinate length when indexed with an out-of-bounds slice.
  • Fixed bug that results in incorrect type narrowing for isinstance or issubclass type guard when the filter is a generic class whose type parameter has a default value.
  • Fixed bug that results in incorrect type evaluation behavior within class body of an enum class when one enum member is used to define another enum member. This involved a significant rewrite of the logic involving enum symbol evaluation.
  • Fixed a bug that results in a false positive error when a decorator is applied to a property.
  • Fixed bug that resulted in false positive when evaluating a function call involving a TypeVarTuple under certain circumstances.
  • Fixed a bug that results in incorrect type evaluation when a function parameterized with a TypeVarTuple is passed as an argument to another function parameterized with a TypeVarTuple.

Behavior Changes:

  • Deferred execution of type annotations (PEP 649) did not make it into Python 3.13 and has been deferred (again) until Python 3.14. Changing pyright's logic accordingly.
  • Changed the type evaluation for type(Any) or type(x) where x is a value of type Any or Unknown. These now evaluate to type[Unknown].
  • Changed the TypeVar scoping behavior for TypeVars that appear only within a Callable subtype within a function's declared return type. Previously, pyright scoped these TypeVars to the Callable rather than the function. This was due to issue #4285. I'm reversing this decision because it's not spec-compliant, creates a bunch of unnecessary complexity, and results in buggy behavior.