Pyright

Latest version: v1.1.390

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

Scan your dependencies

Page 10 of 81

1.1.339

Bug Fixes:
* Fixed a bug that resulted in a false positive error under certain circumstances involving inferred variance, decorators and generic type aliases.
* Fixed a bug that resulted in a false positive when `Self` was used in a value expression outside of a class body.
* Fixed bug that resulted in a false positive error when overriding a TypedDict field when the overridden type was `Any` or vice versa.
* Fixed bug that resulted in a false negative when overriding a TypedDict field with an incompatible `Required` or `NotRequired` attribute.
* Fixed recent regression that resulted in a false negative when `type` or `type[Any]` was used as a type annotation for a field in a dataclass.
* Fixed a bug that results in a false positive when `anext` is passed a value of type `AsyncIterator`.
* Fixed recent regression that results in false positive error where `type` or `type[Any]` is not considered type compatible with `Callable`.
* Fixed bug that affected the case where a TypedDict class derived from two incompatible classes using multiple inheritance. The error was reported in the wrong location.
* Fixed bug that results in incorrect type evaluation when a `raise` statement is used within a context manager that swallows exceptions.
* Fixed bug that led to incorrect type evaluation with unary operator when used with a type alias defined with forward references.
* Fixed bug that resulted in a crash within the function return type checking logic.
* Fixed bug that resulted in incorrect type evaluation when `del` statement is applied to a class member implemented with a descriptor.
* Fixed regression that resulted in a false negative for the `reportUnknownMemberType` check when the expression is a call argument and the member is a function with a partially-unknown signature.
* Fixed a bug that resulted in incorrect type evaluation in certain cases involving generic protocols and bound TypeVars.
* Fixed a bug in the code flow engine that resulted in a false negative for a variable whose type is narrowed within an inner loop.
* Fixed bug that led to improper type narrowing for class patterns when `Callable` is used.
* Fixed bug that resulted in incorrect narrowed type evaluation in certain circumstances involving certain code flow graph structures.

Enhancements:
* Added support in `dataclass_transform` for custom field specifiers that have default arguments for their `init` or `kw_only` parameters.
* Implemented check for inconsistent use of `staticmethod` and `classmethod` in overloads.
* Added support for accessing members of a `TypeAliasType` object.
* Added an error check for a PEP 695 `type` statement within a function body. Type alias definitions are not allowed within this scope.
* Added support for `*args: *Ts` parameter that captures a callable with an indeterminate number of positional parameters because some of them have default arguments.
* (Contribution from jbarrachinab) Improved a few error messages in the Spanish localization.
* Enhanced support for TypeVarTuple capture of a callable to support literal arguments.
* Added a few optimizations that help improve perf somewhat when large unions are involved.
* Added support for doc strings when using the PEP 695 `type` statement.

Behavior Changes:
* Added a new typeCheckingMode called "standard". It's a subset of "strict" but a superset of "basic". It is the new default mode, and it should cover all of the required checks for conformance with the Python typing standard.
* Changed behavior of check for unimplemented methods in a class that explicitly derives from a protocol. If the class also explicitly derives from `abc.ABC`, it is exempted from this check. This is useful for mixin classes.
* Changed behavior of `reportUnknownMemberType` (and other checks in the `reportUnknown...` family) to not report a partially-unknown type if it refers to an unspecialized class.
* Moved checks for Required/NotRequired and ReadOnly overrides from reportGeneralTypeIssue to reportIncompatibleVariableOverride for consistency. Added checks for Required/NotRequired and Readonly incompatibilities in the multiple inheritance case.
* Changed behavior of two-argument form of `super` when it is used outside of an attribute access expression. It now employs a heuristic whereby it evaluates to the next base class of the bound type.
* Changed the type printer logic to avoid emitting truncated `Literal` string and bytes values when it is asked to enforce Python syntax. This mode is used for inlay hints and the stub generator (for inferred return type comments).

1.1.338

Bug Fixes:
* Fixed a bug that results in a false positive error in the `reportUnknownMemberType` check when `abc.Callable` (without any type arguments) is used in the second argument to an `isinstance` call.
* Fixed bug in literal pattern matching that resulted in incorrect narrowing when the subject was typed with a constrained TypeVar.
* Fixed bug that led to incorrect conversion from a class constructor to a function when it involves a `__new__` method that returns `Self`.
* Fixed bug that resulted in crash under certain obscure circumstances where a class with multiple type parameters is explicitly specialized with only a subset of required type arguments.
* Eliminated some differences between the treatment of `type` and `Type`. These should be treated the same under all circumstances.
* Fixed recent regression that resulted in a false positive when accessing a class property from a class instance.
* Fixed a bug that can result in spurious false positive errors when using deeply-nested or recursive type definitions such as `_NestedSequence` in numpy.
* Fixed bug that led to a false negative when `Never` is used as an explicit type argument for a generic class or type alias if the corresponding type parameter is a constrained TypeVar.
* Fixed bug that produces a false negative when attempting to assign a method to a `Callable` type where the first parameter of the method is typed as `Self`, but the callback requires the class itself.
* (from Pylance) Fixed bug that led to false positive errors related to import resolution when a partial stub is used and its directory structure doesn't match that of the library.

Enhancements:
* Improved error handling for failures when explicitly specializing a generic type alias. Improved diagnostic message for `assert_type` failures when printed types look the same when not using the full name of the type.
* Added support for bidirectional type inference for chained assignment expressions.
* Updated typeshed stubs to the latest version.
* Added deprecation message for class properties, which were deprecated in Python 3.11 and are going away in Python 3.13.
* Added support for parameter type inference for lambdas whose parameters include default arguments. This is analogous to the logic used for unannotated function parameters with default arguments.

Behavior Changes:
* Changed the behavior for empty dict or list expressions. Previously, a variable initialized with `{}` or `[]` was not flagged as "partially unknown" by the `reportUnknownArgument` check when used as an argument to a call. This resulted in a small type hole.
* Changed type evaluation logic for member access expressions for `type[Any]` where the target attribute is not explicitly declared in the `type` or `object` class. Previously, pyright emitted an error in this case.

1.1.337

Bug Fixes:
* Fixed a bug that resulted in a false positive when applying a descriptor whose `__get__` method whose `owner` parameter is annotated with `type[T]`.
* Fixed bug that affected the `isinstance` type narrowing logic when the pre-narrowed type is a type alias that refers to a union that includes a recursive type alias.
* Fixed bug in completion provider that resulted in incorrect keyword parameter suggestions for positional-only parameters.
* Fixed bug that led to a spurious "unknown argument type" when passing an unpacked tuple in a call expression.
* Fixed regression that results in a false positive when using a value of type `type[Protocol]` as the second argument to `isinstance` or `issubclass` if the protocol isn't `runtime_checkable`.
* Fixed regression that resulted in false positive errors when a magic method (e.g. `__lt__` or `__add__`) are implemented with a callable protocol object.
* Fixed a bug that resulted in a false positive error when using a walrus operator in a call expression that targets an overloaded function.
* Fixed bug that led to a hang (infinite loop) in the language server when opening a document whose URI wasn't a "file". This occurred in some language servers that used an "untitled" (or similar) URI type for new documents.
* Modified recent bug fix in `isinstance` and `issubclass` type narrowing logic so it better handles type variables with bounds that are unions.
* Fixed a bug that resulted in a false positive error when a higher-order generic function is passed another generic function as an argument along with another argument that dictates the type of the first argument's type variable(s). This shouldn't depend on the order in which the arguments are passed.
* Fixed a bug that resulted in a false positive error when a higher-order generic function is passed another generic function as an argument along with another argument that dictates the type of the first argument's type variable(s). This shouldn't depend on the order in which the arguments are passed.
* Fixed a recent regression that resulted in a false positive error when a parent class defines a property with a getter and a child class extends the property with a setter.
* Fixed bug that led to an incorrect type evaluation when a list comprehension expression is used with bidirectional type inference and the expected type includes a type variable.
* Fixed bug that led to a false positive error when a `__getitem__` returns `Self`.
* Fixed a bug that led to a false positive when determining the type compatibility of two TypedDict definitions whose keys were typed with unions that included two other (compatible) TypedDict definitions.
* Fixed a bug that led to incorrect type evaluation when two lists with different types were concatenated using a `+` operator in a bidirectional inference context.
* Fixed a bug that results in incorrect type evaluation of an index expression when the LHS is unbound. It should produce `Unknown` rather than `Never`.
* Fixed bug that resulted in a false positive under certain circumstances where a recursive type alias was used and hit an internal recursion limit.

Enhancements:
* Improved lambda inference logic to handle the case where the expected type is a callable that accepts a generic callable as a parameter.
* Added error reporting for illegal use of `TypedDict` or `Protocol` within a TypeVar bound or within a type annotation.
* Enhanced `reportInvalidTypeVarUsage` diagnostic message to include a recommended fix.
* Added check for the use of a bare `Literal` (with no type arguments) in places where it's not allowed.

Behavior Change:
* Adjusted heuristic for `reportInvalidTypeVarUse` so it doesn't emit a warning when an unbound TypeVar is used within a subscript.

1.1.336

Bug Fixes:
* Fixed bug that results in an incorrect type evaluation when `functools.partial` is used with a constructor where `type[Self]` is passed as the first argument.
* Fixed bug that resulted in a crash during type analysis.
* Fixed bug that results in false positive when indexing an enum class.
* Fixed a bug that led to a false positive error when calling the same generic function multiple times in a call expression. This bug specifically affected the case where the generic function used PEP 695 syntax.
* Fixed a bug that led to a false negative when a subclass overrides a parent class with an overloaded method in an incompatible manner.
* Fixed bug in the import resolver that allowed typeshed stubs and stub files within installed third-party libraries to take precedence over local modules.
* Fixed a bug that leads an incorrect type evaluation when binding a magic method (like `__add__`) to `self` when the magic method returns `Self`.
* Fixed a bug that resulted in an incorrect type evaluation when accessing a property that returns `Self` or `type[Self]`.
* Fixed bug that resulted in incorrect type evaluation of a symbol imported twice by two redundant wildcard imports.
* Fixed a bug that leads to a false positive `reportPrivateUsage` diagnostic when importing a public symbol from a "py.typed" library if that symbol is imported from a private symbol (and re-exported publicly) within the library.
* Fixed a bug that led to incorrect type evaluation when an inferred method return type includes a union where the subtypes are conditioned on constraints of a constrained TypeVar that parameterizes the class. In this case, one or more of these subtypes should be eliminated when a specialized class is bound to the method.
* Add support non english works in docstring arguments.
* Fix bug in the contravariant return type check where a contravariant used in a union was not reported.

Behavior Changes:
* Changed behavior when converting a class to a callable. If the class has no `__init__` or `__new__` method in its class hierarchy (other than those provided by `object`), pyright previously converted the constructor to a signature of `(*args: Any, **kwargs: Any)`. It now converts it to a signature of `()` (i.e. no params) unless it's a `type[T]` or a protocol class.
* Modified the `isinstance` type narrowing logic to retain a TypeVar when narrowing in the positive case and the value is not a constrained TypeVar.

Enhancements:
* Added "metacls" as an allowed name for the "cls" parameter in a metaclass `__new__` method.
* Improved pyright's enforcement of keyword arguments passed within a `class` statement when the class has no custom metaclass or `__init_subclass__` in its hierarchy. In this case, the `object.__init_subclass__` method applies, and it accepts no additional keyword arguments. Also improved the error reporting for `__init_subclass__` in general.
* Improved handling of `+` operator when both operands are tuples. It now produces a more accurate type when one (but not both) of the two tuples is of indeterminate length.
* Updated typeshed stubs to the latest version.
* Added code to CLI to verify file specs passed on the command line. If they don't exist, emit an error and a non-zero exit code.
* Improved check for second argument to `isinstance` and `issubclass` so non-runtime-checkable protocol classes are rejected.
* Added special-case handling `x in y` narrowing logic for the case where `x` is a `dict` or `Mapping` and `y` is an iterable of `TypedDict`s.
* Added check for the use of contravariant TypeVars in an inferred return type.

1.1.335

Bug Fixes:
* Fixed a bug that resulted in a false positive when validating type consistency between a metaclass instance and `type[T]`.
* Fixed bug that led to an inconsistency between the use of `type` and `Type` when applying `isinstance` type narrowing in some cases.
* Fixed recent regression in the CLI that caused the `--files` command-line parameters to be overridden by the "include" setting in the config file.
* Fixed bug that led to a false positive when assigning a lambda with `*args` to a callable type that doesn't contain `*args`.
* Fixed a few places where union order resulted in different type evaluation behaviors.
* Fixed a bug that led to a false positive error when specializing a type alias consisting of a callable parameterized by a TypeVarTuple.
* Fixed bug that causes a false positive MRO error when creating a subclass of a generic TypedDict and another TypedDict.
* Fixed a bug that results in incorrect type evaluation of a call expression when the callee is a function parameterized by a TypeVarTuple that has been specialized with a concatenation form.
* Fixed several bugs in the signature help provider when handling `**kwargs` parameters typed with an unpacked TypeDict (PEP 692).
* Added missing check described in PEP 692 where fields within an unpacked TypedDict used for `**kwargs` cannot overlap other keyword parameters in the same signature.
* Fixed a false positive `reportIncompatibleMethodOverride` error under certain circumstances where an overloaded method overrides another overloaded method.
* Fixed a bug that resulted in incorrect type evaluation when using a `TypeVarTuple` within a nested `Callable` type (i.e. a `Callable` that takes a `Callable` as a parameter).
* Fixed bug that resulted in false positive reportIncompatibleMethodOverload error under certain circumstances.
* Fixed a bug that causes a false positive `reportUnnecessaryContains` error when `self` is used on the LHS of the `in` operator within an enum class.
* Fixed bug that led to a false negative when assigning type `Class` to `SelfClass`.
* (Contribution by JelleZijlstra) Fix missing space after "not" unary operator for expressions printed in output of `reveal_type`.
* Fixed bug in completion provider that resulted in an attempt to tokenize and parse a binary (native) library file. This led to a crash in some cases.
* Fixed a bug that results in a false positive error when a `__new__` method returns `Self` for a generic class and the type variable is invariant.
* Fixed a bug that led to incorrect type narrowing for the `x is None` in the negative (else) case when `x` is a bound TypeVar (or `Self`).

Enhancements:
* Improved error message for descriptor accesses where binding or type validation fails for the `__get__`, `__set__` or `__delete__` methods.
* Added missing error check for zero-argument form of `super()` when used within a static method.
* Improved error message for member accesses.
* Improved diagnostic message for method overrides based on keyword/position-only parameter mismatch.
* Enhanced the handling of zero-argument form of `super()` to support the case where the containing method's `self` or `cls` parameter is annotated using a protocol. This can be used to handle mixin methods that call `super()`.
* Added support for boolean values in diagnosticSeverityOverrides language server setting.

Other Changes:
* Updated heuristics for constructor evaluation to accommodate a wider range of types returned by the `__new__` method. Previously, if the `__new__` return type was anything other than a class instance, the heuristics assumed it wasn't intended and assumed that `__new__` returned an instance of its class, as is usually the case.
* Restored previous behavior (prior to 1.1.334) where an instance of a class that derives from `Any` will not be considered type compatible with `None`.
* Significant rewrite of code that handles member accesses on class objects and class instances. This should improve internal consistency and fix many edge-case bugs. Due to the extent of this change, some regressions may result.

1.1.334

Bug Fix: Fixed a bug that caused locale override to fail to take effect if passed via the LSP initialize message.

Bug Fix: Fixed issue that led to false positive error when calling a `NoReturn` function within a `case` block or within an `if`/`elif` chain.

Enhancement (contribution by pakrym-stripe): Support unpacked TypedDict in parameter hover.

Performance: Fixed a performance regression that affected symbol type inference in the presence of circular dependencies.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Improved support for runtime `TypeVar`, `TypeVarTuple` and `ParamSpec` objects, including when they are instantiated from `typing_extensions` classes.

Enhancement: Improved inference logic for lambdas so it handles a wider variety of cases including lambas with `*args` parameters and cases where the expected type is a union of multiple subtypes that might be matches.

Enhancement: Improved TypedDict `update` method error message when no overloads match.

Bug Fix: Fixed a bug that led to a false positive when using an unpacked iterable as an argument in a call expression _after_ a keyword argument.

Enhancement: Added support for `python.analysis.include`, `python.analysis.exclude` and `python.analysis.ignore` settings. These have been implemented in pylance for a while now, but they were never implemented previously in pyright. Also fixed a bug in the original implementation that caused the config file not to override the language server settings for `python.analysis.exclude` and `python.analysis.ignore` as it should.

Bug Fix: Fixed bug that led to false negative when evaluating a call to a function with a recursive ParamSpec.

Bug Fix: Fixed a bug in the type guard logic for simple truthy/falsy checks. If the type is an instance of `object` or a `TypeVar` with no bound (which is treated like an `object`), the logic should not assume that it will always evaluate to truthy.

Page 10 of 81

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.