Pyright

Latest version: v1.1.390

Safety actively analyzes 685838 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 81

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 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.

1.1.374

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](https://discuss.python.org/t/copying-signature-of-init-to-a-mixin-class-method/58907/2).
* 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.

1.1.373

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.

1.1.372

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.

1.1.371

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 `SelfT` 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.

1.1.370

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 <class>" 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.

Page 4 of 81

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.