Pyright

Latest version: v1.1.390

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

Scan your dependencies

Page 14 of 81

1.1.316

Note: This will be the last version of pyright published for the next couple of weeks. Responses to bug reports and questions may also be delayed over the next few weeks.

Bug Fix: Fixed a bug in the new `-` command-line feature. This addresses

Bug Fix: Fixed another instance of a false positive `reportMissingTypeArgument` error when a generic class is passed as the second argument to `isinstance`.

Enhancement: Added support for bidirectional type inference when using a dictionary expansion and a dictionary literal expression for an argument corresponding to an unpacked TypedDict `**kwargs` parameter.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when a generic callback protocol was invoked in a nested manner.

Bug Fix: Fixed a bug that resulted in a false positive when passing a class to the `defaultdict` constructor. If an unspecialized class type is used as a upper or lower constraint within the constraint solver, we now use default type arguments (typically `Unknown`) rather than leaving these type arguments unspecified.

Behavior Change: Modified the signature of the synthesized `get` method for TypedDict classes so it more closely matches the signature (and therefore the behavior) of the `get` method in `dict`.

Bug Fix: Fixed regression that caused crash within certain doubly-nested loops.

Bug Fix: Fixed a bug that results in a false positive error when attempting to assign a class to a `Callable` type when the class is generic and the constructor includes class-scoped type variables in its parameter annotations.

Bug Fix: Fixed a bug that led to a false negative when a generic class with called its own constructor using its own type parameters as type arguments.

1.1.315

Bug Fix: Fixed a regression that caused a false positive `reportMissingTypeArgument` diagnostic when using a generic type in conjunction with the `|` union operator in the second argument to an `isinstance` or `issubclass` call.

Bug Fix: Modified protocol matching and the constraint solver to handle an edge case where a partially-solved type variable with a solution of `Any` are provided by other argument types in a call.

Bug Fix: Fixed a bug that leads to a false positive error in the `reportIncompatibleMethodOverride` check when a child class is overriding an overloaded method in the base class and one or more of the overloads doesn't apply because the `self` or `cls` parameter is explicitly annotated in a way that's not applicable to the child class.

Bug Fix: Fixed a bug in type evaluation of the two-argument form of the `super` call. There were situations where the incorrect MRO class was used.

Bug Fix: Fixed bug that led to false positive errors when performing protocol matching in certain circumstances.

Bug Fix: Fixed a bug that led to a false positive when passing unpacked lists or dictionaries to a constructor for a class that doesn't provide its own constructor and falls back to the `object` constructor.

Bug Fix: Changed parameter type inference logic to avoid inferring the type of an unannotated parameter with a default value consisting of a lambda.

Bug Fix: Fixed a regression that caused an incorrect type evaluation of a function that returns a callable with a ParamSpec that does not appear outside of the return type annotation. A previous fix didn't correctly handle the case that involved a class parameterized with a ParamSpec.

Bug Fix: Fixed a false negative where an unpacked dictionary argument was not validated against the `**kwargs` parameter type.

Bug Fix: Fixed several subtle bugs in the overload matching algorithm in the case where Any or Unknown arguments are present.

Enhancement: Improved the heuristic used to determine which subtypes of a union within an "expected type" should be used for bidirectional type inference.

Bug Fix: Fixed bug that led to an incorrect type evaluation for nested call expressions where an inner call expression used a ParamSpec.

Bug Fix: Fixed false negative when a literal and non-literal are assigned to the same TypeVar in an invariant context.

Behavior Change: Changed auto-variance algorithm to ignore `__new__` and `__init__` methods for purposes of calculating the variance of a TypeVar. This mirrors the behavior of mypy.

Bug Fix: Fixed a bug that led to incorrect type evaluation when passing a generic class (with a constructor that includes class-scoped TypeVars) as an argument for a callable parameter. The class was being specialized prematurely (with type arguments set to `Unknown`) before the constraint solver was able to solve the higher-order function's type variables.

Bug Fix: Fixed a false positive error arising from the use of a binary expression for a base class in a class declaration statement.

Enhancement: Improved hover text to display the calculated variance for a PEP 695-style class-scoped type variable when the user hovers over the type parameter in the type param list.

Bug Fix: Fixed a bug that led to a false positive error under certain circumstances when a literal type argument was used in conjunction with a protocol that used a covariant type parameter and an implementation of that protocol that used an invariant type parameter.

Behavior Change: Changed type printer (the component that renders types into text) to use the lowercase `type[x]` instead of `Type[x]`. It has now been four years since PEP 585 deprecated the use of the upper-case version, so most developers should be getting comfortable with the lowercase version at this point.

Enhancement: Improved `reportUnnecessaryCast` so it works with types other than class instances.

Enhancement: Improved type inference for lambdas in the case where a parameter includes a default value and the expected type doesn't include that parameter.

Bug Fix: Fixed bug in code flow engine that led to incorrect type evaluation of a variable in a nested loop.

Bug Fix: Fixed bug that resulted in a false positive error when defining a new type alias using the `TypeAliasType` constructor that defines no new type parameters but references an outer-scoped type parameter in the type alias definition.

Enhancement: Enhanced command-line version of pyright to allow file or directory names to be passed via stdin if `-` option is used in the command line.

Behavior Change: Changed behavior of non-ClassVar variables within a protocol definition. Previously, an error was reported when such variables were accessed from the class (as opposed to an instance of the class). Mypy (which was the reference implementation for PEP 544) does not report an error here.

Bug Fix: Fixed a bug that caused incorrect type inference for parameters in unannotated methods within child classes who derive from a generic parent class.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that caused an incorrect false positive error for an `assert_type` call involving a `Callable[[], X]` type. Pyright was generating a signature with a positional-only separator in this case.

Enhancement (contributed by debonte): Added support for PEP 712's new attribute assignment conversion.

Performance: Fixed a bug in type caching mechanism that could have resulted in poor performance in certain circumstances.

Performance: Added low-level caching mechanism for converting between instance and instantiation types. This should reduce memory usage in some circumstances.

Enhancement: Enhanced the `isinstance` type narrowing logic so it filters types based on the number of entries in a tuple if the type derives from a tuple.

1.1.314

Enhancement: Updated typeshed stubs to the latest version. This update includes some substantive changes to stdlib protocols and classes related to buffers. These changes will result in some compatibility issues for some libraries. For more details about the motivation for these changes, refer to [PEP 688](https://peps.python.org/pep-0688/).

Regression Tests: Upgraded pyright’s CI process to include the execution of mypy_primer, a tool that was written by hauntsaninja for mypy and typeshed to catch regressions. He extended the tool to support pyright. If you are a repo owner who uses pyright in your CI and would like us to include your project in pyright’s CI (to understand and prevent regressions that could affect your project), let us know.

Bug Fix: Fixed bug that resulted in a false negative when using the `reportMissingTypeArgument` check when defining an old-style type alias. This same bug resulted in inconsistent behavior between `Union` and `|`, which should be equivalent.

Bug Fix: Fixed a bug in the typeshed VERSIONS exclusions. It was falling back on the VERSIONS file in the packaged typeshed rather than using the custom typeshed path specified in the configuration or command line.

Bug Fix: Fixed a bug that led to a false negative when passing an unpacked tuple of length one to a function that requires more (or fewer) than one positional argument.

Performance: Reverted a recent internal refactoring because it resulted in increased peak memory usage in some cases.

Bug Fix: Fixed false positive error when using a `*args: P.args` as the first parameter in a method.

Bug Fix: Improved the protocol matching logic so it honors partially-solved type variables whose values are provided by other argument types in a call.

Bug Fix: Fixed a bug that led to infinite analysis time and heap exhaustion when analyzing an overloaded function that includes a ParamSpec that uses itself as an argument.

Bug Fix: Fixed a bug that led to a false positive `reportIncompatibleMethodOverride` error for overloaded method overrides in cases where the overloads are differentiated based on explicit types for the `self` or `cls` parameter.

Bug Fix: Fixed a regression that caused an incorrect type evaluation of a function that returns a callable with a ParamSpec that does not appear outside of the return type annotation.

1.1.313

This is a hot-fix release aiming to address a specific regression in pyright 1.1.312 reported [here](https://github.com/microsoft/pyright/issues/5243).

Bug Fix: Reverted latest typeshed updates that caused a regression related to buffer types.

1.1.312

Bug Fix: Fixed a bug that results in a false positive when calling a generic function that has a declared return type of a tuple and the call has an expected type (bidirectional type inference).

Enhancement: Enhanced `reportIncompatibleMethodOverride` diagnostic check to support cases where the overridden function is overloaded. Attempted to duplicate the same logic that's in mypy for compatibility.

Bug Fix: Fixed a bug that resulted in a false positive in certain obscure cases involving callables with parameters that are typed using TypeVarTuples.

Bug Fix: Fixed a bug that led to false positive errors when a generic function was called in a nested manner (i.e. invoked as in an argument expression).

Bug Fix: Fixed a bug that resulted in the incorrect return type inference for an async function that has no type annotations.

Bug Fix: Fixed bug that resulted in a false positive error when using a nested `Literal` that includes `None`.

Bug Fix: Fixed a bug that led to extremely long (effectively infinite) evaluation times when a generic function was passed as an argument to itself.

Behavior Change: Changed the matching of an unpacked dictionary passed as an argument to a callable when keyword arguments are present and have default values. Previously, the types of all such parameters were not checked against the unpacked dict type (under the assumption that the default argument would satisfy the parameter in this case). The new behavior matches that of mypy and assumes that the unpacked dict may supply arguments for all otherwise-unmatched keyword parameters even if they have default argument values.

Enhancement: Added auto-exclude logic specifically for typeshed so stdlib stubs that are not "in scope" for the current python version are auto-excluded from the project. This applies only if the `typeshedPath` is set to `.`.

Bug Fix: Fixed issue that caused a false positive error in typeshed CI due to nondeterministic handling of circular dependency in `ReprEnum` class.

Bug Fix: Fixed a bug that led to a false positive error when validating the consistency of the return type of a generator function if the return type declaration was not specifically `Generator` or `Iterable` (or their async counterparts).

Bug Fix: Fixed a false negative type error involving a recursive type alias that includes a `Sequence` and a `str` (which is itself a recursive type involving `Sequence`).

Bug Fix: Fixed a bug that led to a false positive error when a call expression was used on the RHS of an "or" or "and" operator and the target callable involved an overload with a function-scoped TypeVar in the return type.

Bug Fix: Fixed a bug in the tokenizer that led to an incorrect error for an f-string that ends in a double backslash.

Bug Fix: Improved evaluation of nested calls that involve the same generic function or multiple uses of the same generic function as arguments to the same call. In these cases, the generic signatures need to be made unique so the type variables of each are treated as though they are independent.

Enhancement: Updated typeshed stubs to the latest version.

1.1.311

Bug Fix: Fixed regression in f-string tokenization that led to a false positive error when an escape character (backslash) is used with a carriage return or line feed within the non-expression part of an f-string.

Bug Fix: Fixed a bug that resulted in a crash in certain cases within the argument/parameter matching logic.

Bug Fix: Fixed recent regression that led to a false negative when using `functools.partial` with bidirectional type inference.

Bug Fix: Fixed a bug that led to (temporary) sporadic `reportUnnecessaryTypeIgnoreComment` errors.

Bug Fix: Fixed a recent regression that affected a function that returned a generic `Callable` that used `type[T]` rather than `T` in the type annotation.

Bug Fix: Fixed a recent regression that resulted in the incorrect evaluation of the `value` field for an `Enum`.

Bug Fix: Fixed a bug that led to an unsolved type variable within a union producing an `Unknown` type in some cases. This triggers false positive errors in strict mode.

Bug Fix: Fixed a bug that allowed unsolved type parameters to "leak" from a `__new__` call in some cases.

Bug Fix: Fixed a bug that led to a false positive when a function-scoped ParamSpec was used within a constructor, and a lambda with no parameters is passed to the constructor as an argument.

Bug Fix: Fixed a bug that led to false positive errors for a constructor call used in conjunction with bidirectional type inference for a generic class that includes both a `__new__` and an `__init__` method.

Bug Fix: Fixed a bug that led to incorrect handling of ` type: ignore` comments if a file is type checked but then pyright runs low on memory and is forced to dispose of cached parse information. We now precompute the accumulated diagnostics while the cached parse information is available.

Bug Fix: Fixed a bug that led to a crash when running `pyright --verifytypes numpy`. A pathological case in the numpy code was causing an exponential explosion in the number of type variable signature contexts.

Page 14 of 81

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.