Pyright

Latest version: v1.1.390

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

Scan your dependencies

Page 13 of 81

1.1.322

This is a hot fix release to address a regression in 1.1.321.

Bug Fix: Fixed recent regression that led to a false positive when assigning a union of types that use invariant type parameters to a protocol that uses a covariant type parameter. This fix was already incorporated into this week's preview release of pylance (v2023.8.21), so it shouldn't affect pylance users.

Bug Fix: Fixed a bug that led to a spurious "Unknown" type when an assignment to a variable with a type annotation was used within a loop.

Bug Fix: Fixed false positive error when an empty tuple was used in an `except` statement.

1.1.321

Behavior Change (from pylance): Import suggestions are filtered when py.typed is available based on whether the symbol is considered public or private.

Bug Fix: Fixed a bug that led to a false positive in certain cases where a ParamSpec captures an overloaded function signature.

Bug Fix: Fixed a bug that resulted in a type evaluation error when using bidirectional type inference with a non-generic protocol.

Bug Fix: Fixed a bug that resulted in an off-by-one error in an error message when reporting the index of a mismatched overload.

Bug Fix: Fixed a bug that resulted in a false positive `reportIncompatibleMethodOverride` diagnostic when the base method used a double underscore to indicate position-only parameters but the override used the newer `/` separator.

Bug Fix: Revert "Fixed a bug that led to a false negative when determining whether two base classes that are combined using multiple inheritance implement the same method in an incompatible way. The bug caused the check to be skipped if the child class also implemented the same method as the two base classes.

Bug Fix: Fixed a bug that resulted in an incorrect hover type (and inlay hint) for the inferred return type of an `async` function or method.

Performance: Addressed a performance regression introduced in 1.1.314 due to a switch from ts-loader to esbuild-loader in our build pipeline. This change resulted in a 7-9% performance degradation, so I'm reverting it for now.

Enhancement: Added check for improper use of a type alias defined using the `type` statement introduced in PEP 695.

Bug Fix: Fixed bug that led to a false positive error in certain cases when using bidirectional type inference when the expected type includes a protocol that is specialized with a literal type argument.

Bug Fix: Fixed a bug that led to incorrect type narrowing on assignment in certain cases where the declared type includes a type argument with an `Any` and the assigned type does not.

1.1.320

Bug Fix: Reverted new version of `chalk` library. The newer version is not compatible with node v12.

Bug Fix: Fixed a bug that resulted in a false positive error when attempting to assign a TypeVar `T` that has a bound of `type` to an expression `type[S]`.

Enhancement: Added a new configuration options flag called `enableExperimentalFeatures` that controls whether certain experimental features are enabled. Currently there are three features under this flag: `StrictTypeGuard`, `ReadOnly` fields for typed dicts, and inlined `TypedDict` definitions.

Enhancement: Removed support for experimental `StrictTypeGuard` and replaced it with an experimental variant of `TypeGuard` that applies strict semantics if certain conditions are met.

Bug Fix: Fixed a bug that led to incorrect variance inference when a value annotated with a class-scoped TypeVar was assigned to an instance variable.

Behavior Change: Updated heuristics for how to handle custom metaclass `__call__` methods based on feedback. Previously, if a metaclass `__call__` method was present, pyright assumed that `__new__` and `__init__` may not be called, so it ignored them. The new heuristic assumes that if the metaclass `__call__` returns a type that is consistent with the expected return type of `type.__call__` that it is probably mirroring the behavior of `type.__call__` and calling the class' `__new__` and `__init__` methods.

Behavior Change: Changed auto-variance algorithm to exempt class and instance variables that are named as protected or private.

Bug Fix: Fixed a regression that caused class decorators of generic classes to no longer be specializable.

Bug Fix: Fixed a bug that resulted in an apparent hang within the type printing logic. This was triggered by a pathological case involving a deeply recursive type.

Behavior Change: Modified type inference logic so methods that raise an exception whose type derives from `NotImplementedError` is not inferred to return `NoReturn`. Previously, only `NotImplementedError` was exempted, not subclasses.

Behavior Change: Removed old code that looks for a `typeshed` override in the standard python search paths. This works around an issue with the `inject` library, which installs a bogus `typeshed` directory into `site-packages`.

Bug Fix: Fixed a bug that results in unsolved type variables in a call return if the target function's return type is a callable that has type variables that are scoped to that callable.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when a generic function that returns a callable is passed itself as an argument and the resulting callable is then called and passed that same function as an argument.

Bug Fix: Fixed a bug in the command-line version of pyright where it did not enable "auto search paths", so it didn't automatically add "src" as an extra path.

Bug Fix: Fixed a bug that led to a false negative when determining whether two base classes that are combined using multiple inheritance implement the same method in an incompatible way. The bug caused the check to be skipped if the child class also implemented the same method as the two base classes.

Bug Fix: Fixed a bug that resulted in a false positive error when using an unpack operator within a call to an overloaded function.

Bug Fix: Fixed a bug that resulted in a false positive error when a captured variable within an inner scope (function or lambda) is imported from another module using an import statement that comes after the function or lambda.

Bug Fix: Fixed bug that led to incorrect type evaluation when accessing the `name` attribute on an enum.

1.1.319

Bug Fix: Fixed a bug that results in a crash when attempting to use a member access expression where the LHS is a TypeVarTuple.

Bug Fix: Fixed a bug that led to a false negative when analyzing code with an async context manager that swallows exceptions.

Enhancement: Improved error messages for situations where a call expression targets an overloaded function or method and there are no matches. Added some heuristics to pick the "best" overload function for the error message. Previously, pyright used the last overload, but this sometimes led to confusing errors.

Enhancement: Added support for the `X is C` and `X is not C` type guard pattern (where `C` is a class).

Bug Fix: Fixed an issue in type evaluation of call expressions where the callable subexpression evaluates to a union, and the callable subtypes have different signatures. Pyright was previously caching the types from the first subtype, so it didn't re-evaluate using the second subtype (which may require bidirectional type inference).

Bug Fix: Fixed bug in hover text where it was not producing the correct text output for an instantiable callable.

Enhancement: Added detection and reporting of illegal use of `type[Callable]` within a type annotation.

Bug Fix: Fixed a bug that resulted in a false positive error when bidirectional type inference was used with a class that defines a `__new__` method within a generic class that returns an instance of the class whose type arguments do not match the type parameters.

Bug Fix: Fixed an inconsistency in reporting of unbound variables when the variable is captured by an inner scope. The new behavior correctly identifies unbound (or potentially unbound) variables in cases where the captured variable is narrowed. This happens when there are no assignments to the variable after it is captured.

Bug Fix: Fixed a bug that led to a false positive when a constrained type variable was used as a type argument in an annotation for an argument passed to a method that's bound to the same type variable.

Bug Fix: Improved robustness of handling of circular dependencies for class evaluations.

Enhancement: Enhanced support for `functools.partial` so it supports classes (constructors) when passed as the first argument.

Bug Fix: Fixed a bug that led to a false positive error when using bidirectional type inference for a dictionary expression when the expected type is a protocol.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that led to a hang and eventual crash (due to memory exhaustion) under certain circumstances where a function returns a generic `Callable` whose type parameters are not used in the input parameters for the function.

Bug Fix: Modified the heuristics used for narrowing on assignment when the assigned type contains an `Any`. If the target's declared type does not contain `Any`, the assignment shouldn't produce an `Any` within the resulting type.

Enhancement: Added support within the constraint solver for higher-order functions that accept a callable parameterized with a ParamSpec where the passed callable is generic.

Bug Fix: Fixed a bug that resulted in the incorrect inferred variance for a type variable used within a frozen dataclass.

Bug Fix: Fixed a theoretical bug in the code that detects unique type signatures. It wasn't correctly handling constructor methods.

Bug Fix: Added support for type narrowing of a class pattern when the specified class is `type()` or a subtype thereof and the subject contains a `type[X]` whose metaclass potentially matches the pattern.

1.1.318

Performance: Added code to handle pathological case in unannotated code that assigns values to the same variable hundreds of times with different types.

Bug Fix: Fixed a recent regression that resulted in unsolved type arguments when a "bare" generic class (like `dict`) is passed as an argument to a function that accepts a `type[T]`.

Bug Fix: Fixed a bug in type narrowing for pattern matching in the negative (fall-through) case when the subject type contains an `Any`.

Enhancement: Added additional special-case handling for `__init_subclass__` and `__class_getitem__` to treat them as implicit class methods even if they are not declared using a `def` statement.

Bug Fix: Fixed bugs that resulted in incorrect or incomplete types when narrowing for sequence patterns in the negative case and the subject expression is a super-type of `Sequence` (such as `object` or `Reversible`).

Behavior Change: Modified `is None` type guard logic to eliminate `Any` or `Unknown` in the positive narrowing case.

Bug Fix: Fixed bug that resulted in a false positive `reportOverlappingOverload` error when overload contained the use of a constrained TypeVar.

Bug Fix (thanks to adpauls for contribution): Add fsevents as optional dependency to public package. This should improve file watcher behavior for large projects on MacOS.

Enhancement: Improved the error message for incompatible type arguments. Many users are confused about variance (in particular invariant type parameters). This change should help eliminate some of that confusion.

Bug Fix: Fixed a bug that resulted in a false negative when assigning a `T | None` type to `object | None` in an invariant context. This same bug led to issues with the validation of TypeVar variance within a Protocol.

Bug Fix: Fixed recent regression that resulted in a false positive error when using bidirectional type inference for an assignment to a class-scoped variable where the annotated type is a descriptor.

Enhancement: Improved checks for illegal use of a variable within a type expression. Added enforcement of these same rules for the first argument to a `cast` call.

Behavior Change: Removed the requirement that a `TypedDict` be marked `final` for it to be considered for type narrowing as part of a `S in D` type guard pattern. This requirement wasn't sound because TypedDict is a structural type (i.e. a protocol), so `final` doesn't have any real meaning.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed bug that caused an error to go undetected when the LHS of a call expression is a union that includes an abstract static or class method.

Bug Fix: Fixed a bug that resulted in incorrect evaluation of a type alias defined with `typing.TypeAlias` and consisting of a single (naked) type variable.

Bug Fix: Fixed a bug that resulted in a false positive when an expression of type `type[Self]` was used as the base type for a member access expression that was then used to call an instance method on that class.

Bug Fix: Fixed a bug that led to a false negative when determining type compatibility between two unions in an invariant context.

Bug Fix: Fixed bug that resulted in the incorrect variance inference of an "auto variance" type parameter (as introduced in PEP 695).

1.1.317

Bug Fix: Fixed a regression that caused a false positive when comparing type compatibility between two `Callable` types that involve ParamSpecs.

Behavior Change: Changed '-' command-line feature to support multi-line input.

Enhancement: Added special-case support for enum fields that are assigned using an unpacked tuple operation.

Bug Fix: Fixed bug that resulted in false positive error when calling the same generic function with a ParamSpec multiple times as separate arguments within a call expression.

Bug Fix: Fixed another ParamSpec-related issue.

Enhancement: Extended support for TypedDict discrimination by literal field so it supports `==` and `!=` with values that are unions of literal types.

Bug Fix: Fixed a bug that resulted in incorrect hover results for identifiers used as keys or values within a dictionary expression.

Bug Fix: Fixed recent regression in the synthesized TypedDict `get` method, which resulted in a false positive error when using strict mode.

Enhancement: Removed limitation that files specified on the command line or in "include" directives end in ".py" or ".pyi".

Bug Fix: Fixed a bug that results in incorrect type evaluation for a higher-order function involving a ParamSpec.

Behavior Change: Modified diagnostic checks for list, dictionary, and tuple literal expressions within annotation expressions so they are emitted as part of the `reportGeneralTypeIssue` diagnostic rule rather than unconditionally.

Bug Fix: Fixed bug that led to a confusing hover type for the return result of an async generator function.

Enhancement: Added support for deferred annotation evaluation for `Annotated` type arguments beyond the first one.

Bug Fix: Improved assignment mismatch errors to better handle the case where the two types have the same short name but different fully-qualified names. In this case, the types are now expanded to avoid confusion.

Bug Fix: Fixed incorrect type mismatch error messages within constraint solver logic. The source and destination types were swapped, which led to confusing messages.

Performance: Improved protocol type cache for improved type analysis performance in code bases that make heavy use of protocols.

Enhancement: Added detection of errors when a namedtuple definition includes a language keyword. Also added minimal support for the `rename` parameter to the `namedtuple` function.

Enhancement: Updated typeshed stubs to the latest version.

Page 13 of 81

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.