Pyright

Latest version: v1.1.390

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

Scan your dependencies

Page 16 of 81

1.1.304

Bug Fix: Fixed recent regression that led to a false positive error when `useLibraryCodeForTypes` was false and an import of the form `from a.b import c` targeted a namespace package `a.b` that contains a traditional package `c`.

Bug Fix: Fixed bug that resulted in incorrect type narrowing for `case` statements that involved sequence patterns when the subject included a recursive type alias.

Enhancement: Added support for `functools.partial` when the provided function is overloaded.

Bug Fix: Fixed bug that resulted in a false positive when evaluating the types of nested generic function calls when bidirectional type inference is required.

Bug Fix: Fixed bug that resulted in an unresolved `Unknown` type in a doubly-nested loop when the value comes from a call to an overloaded function or magic method.

Enhancement: Improved type inference for enum values in an enum class created with the one-line form `x = Enum("x", "a b c")`.

Bug Fix: Improved error handling for enum classes created with the one-line form `x = Enum("x", "a b c")`. The code now handles other whitespaces and commas and properly checks for format strings.

Enhancement: Added support for other functional Enum calls including a list of strings, a tuple of strings, a list of tuples, a tuple of tuples, and a map.

Enhancement: Added support for type evaluation of lambdas that are immediately called. The inferred types of the lambda's parameters must be inferred from the argument types in this case.

Bug Fix: Fixed recent regression that causes a false positive when a variable is assigned an expression of `...` within a type stub file and strict type checking is enabled.

Bug Fix: Fixed a bug that leads to a false positive error when evaluating the type of a method that contains a function-scoped ParamSpec when the method is partially specialized through a binding operation.

Enhancement: Improved overload filtering for constructor calls when the class defines no `__init__` but does define an overloaded `__new__`.

Enhancement: Added limited support for type narrowing of subexpressions of the subject expression for match statements. In particular, added support for discriminated TypedDicts and tuples that are discriminated on literals.

Enhancement: Enhanced type narrowing in the negative (not matched) case for sequence pattern matching when the subject is a tuple of known length. In cases where the pattern narrows one tuple entry in the positive case, we can eliminate that subtype in the negative case.

Enhancement: Enhanced type narrowing for pattern matching in cases where the subject is a tuple expression and one of the entries is a subexpression that is later used in a case statement block.

1.1.303

Behavior Change: **This change may require changes to your configuration.** Changed the default of the `useLibraryCodeForTypes` from false to true to bring pylance and pyright into alignment. Also deprecated the "--lib" command-line option, which was previously used to enable `useLibraryCodeForTypes` from the command line. If your project relies on the old default value, you will need to explicitly set `useLibraryCodeForTypes` to false in your project’s configuration file.

Behavior Change: Changed `reportImportCycles` so it is not on by default in "strict" type checking mode. It is highly opinionated and should be used only in cases where the developer opts into it.

Enhancement: Improved the synthesized `__init__` method of a `TypedDict` class so it accepts another instance of the same TypedDict (or another TypedDict that is type compatible) as an argument. This makes pyright compatible with mypy in this regard.

Bug Fix: Added the ability for any callable to conform to a protocol that includes attributes and methods defined in the pseudo-class `builtins.function`.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when a partially-specialized generic method (with method-scoped type variables) is passed multiple times to a function that accepts generic callables.

Behavior Change: Reverted recent change that validated that explicitly-annotated `self` and `cls` in overloaded methods was a subtype of the class that contains them. This change made pyright consistent with mypy, but feedback from pyright users indicated that it was not desired. There are legitimate use cases for this in the overload case.

Bug Fix: Fixed bug that led to incorrect type narrowing for mapping patters in a `case` statement if the type included a recursive type alias.

Bug Fix: Fixed bug that potentially resulted in internally corrupted state when a `class` or `def` statement appears within a conditional block that is determined by the binder to be unreachable.

Bug Fix: Fixed a bug that resulted in a false positive error when assigning a function that has one or more tuple parameters to a generic callable that also accepts tuple parameters.

Bug Fix: Fixed a bug that led to a false positive error when combining a generic callback argument with a second argument that is an empty dict expression.

Bug Fix: Fixed bug in typePrinter that caused syntactically-incorrect output when using the "PythonSyntax" flag and passing a callable type that has a `ParamSpec` but no additional concatenated parameters.

Performance: Improved internal type caching mechanism used in cases where evaluation needs to be done speculatively (e.g. when evaluating argument expressions for an overloaded function). The previous code consumed significant memory and CPU cycles in certain circumstances.

1.1.302

Bug Fix: Fixed bug that resulted in a false positive "partially unknown" error when using an augmented assignment targeting a subscripted expression within a loop.

Bug Fix: Fixed regression in CLI version that caused the default `stubsPath` value to stop working. This regression didn't affect the language server code paths.

Bug Fix: Fixed a bug that caused an overload function with a missing return type annotation (and a placeholder body) to have an inferred return type of `None` when it should be `Unknown`.

Enhancement: Added support for negative (fall-through) type narrowing for mapping patterns used in a `case` statement when the subject type includes a TypedDict with a discriminated field type (i.e. a field whose value is limited to a particular literal value).

Bug Fix: Fixed bug in constraint solver that results in incorrect code being emitted when overriding a method that includes multiple keyword-only parameters.

Bug Fix: Fixed bug that led to inconsistent behaviors when attempting to assign callable with a tuple parameter where the tuple was of indeterminate length. Previously, this generated an error if the source type parameter was a tuple with zero elements.

Enhancement: Added support for type guards of the form `x[I] is B` and `x[I] is not B` where `x` is a tuple and `B` is a boolean literal `True` or `False` or an enum literal.

Enhancement: Implemented PEP 698 (override) support for methods decorated with `property` decorator.

Bug Fix: Fixed a bug that resulted in a false negative when a `self` or `cls` parameter has an incorrect type annotation (not a subtype of the containing class) in an overloaded method.

Bug Fix: Fixed a bug that led to a false positive error when evaluating a call expression that accepts multiple generic callables, at least one of which is parameterized by a `ParamSpec`, where the generic types of the callables interact when being solved.

Performance: Fixed an issue that resulted in an unnecessary use of memory when transforming certain types that include TypeVars.

Bug Fix: Fixed a bug that led to a false positive when a generic function was passed as an argument to another generic function multiple times. In such a case, the second (and subsequent) instances of the function must be given unique type parameters so they are distinguished from other instances of the same function.

Bug Fix: Changed the evaluated type of an exception group from `ExceptionGroup` to `BaseExceptionGroup`.

Bug Fix: Improved type inference for unpacking of tuples that include unpacked tuples whose lengths are unknown.

Bug Fix: Fixed a bug that led to a false positive error when calling a constructor using bidirectional type inference on a generic class that defines a `__new__` method but no `__init__` method.

Bug Fix: Fixed bug that resulted in a false negative when `Never` is used as a type argument for an invariant type parameter.

Bug Fix: Fixed a bug that led to a false positive error when applying bidirectional type inference to a call expression that invokes a generic function where the return type includes a generic class with multiple type arguments, some of which are supplied by the expected type and some of which are not.

Bug Fix: Fixed bug that resulted in incorrect type narrowing in the negative (fall-through) case for certain value patterns in a `match` statement.

Enhancement: Updated typeshed stubs to the latest version.

1.1.301

Bug Fix: Fixed bug that caused diagnostic for implicit override to be reported as part of `reportGeneralTypeIssue` rather than `reportImplicitOverride.

Bug Fix: Fixed recent regression that caused a crash in the signature help provider.

Bug Fix: Fixed bug that resulted in false positive "incompatible variance" error when covariant and contravariant type variables were used in certain combinations when defining a generic class.

Enhancement: Added support for argument dictionary unpacking when the type of the unpacked object supports the SupportsKeysAndGetItem protocol. Previously, the object needed to be an explicit subclass of Mapping.

Bug Fix: Fixed a bug that led to the incorrect evaluation of a symbol imported through a `from a.b import c` statement if `a.b` is a non-py.typed library, useLibraryCodeForTypes is false and `c` was also the name of a submodule of a.b. In this case, the evaluated type of `c` should be `Unknown`, but it was incorrectly evaluated as a module type.

Behavior Change: Reduced verbosity of CLI output for non-error conditions.

Enhancement: Added support for a TypeGuard function where the first argument is a TypeVar. In this case, the resulting (narrowed) type should be a conditional type that references the TypeVar.

Bug Fix: Added support for "naked" `ClassVar` used to annotate a class variable that is assigned a descriptor object but is later set through an object member access. This previously resulted in a false positive error.

Enhancement: Added support for synthesized `__slots__` symbol in dataclasses that are constructed using the `slots=True` argument.

Bug Fix: Fixed bug that resulted in an false positive error when using a class (and by implication, its constructor) as an input to a generic function (e.g. a decorator) that is parameterized with a ParamSpec.

Bug Fix: Fixed a bug that resulted in a false negative when using a type variable with an incompatible variance to specialize a generic class that uses a TypeVarTuple.

Bug Fix: Fixed bug that resulted in a false positive error when doing protocol matching where the object type (i.e. the `self` value) is a literal value.

Behavior Change: Tweaked the type constraint solver's "scoring" mechanism to ensure that functions and function overloads are always scored as "more complex" than classes, objects and unions thereof.

Performance: Fixed issue that resulted in unnecessary caching (and therefore unnecessary memory usage) for instances of types that are already considered instances, such as `Any` and `Unknown`.

Bug Fix: Fixed a bug that resulted in spurious type evaluation errors when dealing with classes that have synthesized symbols such as dataclasses, namedtuples and TypedDicts.

Bug Fix: Fixed bug that led to a false positive error when a TypeVar was bound to `StringLiteral` and conditionally narrowed.

1.1.300

Bug Fix: Fixed regression that resulted in a false positive error when using an index expression form with a class whose metaclass supplies a `__getitem__` method when the expression is used as a runtime expression, as opposed to a type expression.

Performance: sped up type analyzer by 5-25% by caching types that have been converted to or from an instance. This drops the analysis time of pydantic from 17s to 12s.

Performance: Further improved perf when determining type compatibility of unions with many subtypes. This further reduces the analysis time of pydantic from 12s to 4s.

Enhancement: Added new diagnostic check `reportImplicitOverride`.

Bug Fix: Fixed bug that resulted in a false positive error relating to variance incompatibility.

Bug Fix: Fixed regression that caused a crash in the presence of the illegal statement `import .`.

Behavior Change: Changed the logic in the code flow engine so it never attempts to infer a NoReturn return type for a function that lacks a return type annotation. This results in a big speed improvement for some (unannotated) code bases, but it also produces somewhat inconsistent type evaluation results because a function whose type is inferred to be NoReturn by the type checker will not be treated as such if it is called elsewhere in the program.

Bug Fix: Fixed bug that resulted in a crash when user types `import` without a follow-on module name. This can happen in due corse of typing an import statement.

Bug Fix: Added support for `clear` and `popitem` methods on TypedDict instance that is marked `final` and has no required entries.

Bug Fix: Improved hover text for methods that are synthesized (e.g. the `get` method for TypedDict).

Behavior Change: When stub generator encounters an import statement within a try block, it now emits it rather than ignoring it.

Bug Fix: Fixed a bug that can result in infinite recursion (and a subsequent crash) when a class instance is called and the class defines a `__getattr__` method.

Enhancement: Added support for `deprecated` in an `__init__` method when constructing a class.

Bug Fix: Fixed a couple of bugs in the type narrowing logic for class pattern matching. In particular, added better support for `NoneType()` patterns and cases where the subject type is a union that includes subtypes of the class pattern.

Behavior Change: Improved consistency of type narrowing on assignment when the target is a variable with a declared type and the assigned value is an unknown or partially-unknown type. Previously, if the assigned value was Unknown, the declared type was assumed, but if the assigned value was a union that included Unknown, the narrowed type (including the Unknown) was assumed. We now always include an `Unknown` in the assigned type so the `reportUnknownVariableType` diagnostic is reported.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that led to the incorrect type resolution for unsupported function Enum class construction. The resulting type should be `Unknown`, but it was evaluated as `Never`.

Enhancement: Extended support for reportUnnecessaryComparison check to handle dataclass types that use a synthesized `__eq__` method.

Bug Fix: Fixed regression that resulted in internal corrupt state and odd behaviors like builtin symbols being marked as "not found" in some circumstances.

Bug Fix: Fixed a recent regression that resulted in a false positive error when a multi-part import statement was used and `useLibraryCodeForTypes` was disabled.

1.1.299

Bug Fix: Fixed bug that caused incorrect evaluation of numeric literals expressed as binary, octal, or hex. These literals were incorrectly represented as "big integers" in some cases, which caused some operations to fail during type checking.

Bug Fix: Fixed display issue with name of module when it is imported implicitly as part of a multi-part import.

Behavior Change: Changed ` pyright: basic` file-level comment so it overrides "strict" settings specified in the config file or language server settings. This allows an individual file to be "downgraded" from strict to basic.

Bug Fix: Fixed a recent regression that resulted in multi-part imports being evaluated as unknown if a namespace package was used for an intermediate part of the module path and `useLibraryCodeForTypes` was set to false.

Bug Fix: Fixed regression that led to a false positive error in some cases where when a wildcard pattern is used in a `case` statement within a loop.

Enhancement: Updated logic for PEP 696 (TypeVarLike "defaults") to change the syntax for ParamSpec default expressions.

Bug Fix: Fixed bug that caused incorrect results with `--verifytypes` when `NewType` was used to define a type prior to Python 3.9.

Bug Fix: Fixed a bug that led to a false negative when a non-Generic class has a metaclass that defines a `__getitem__` method.

Bug Fix: Fixed a bug that led to incorrect "circular reference" error for a type alias declaration in certain circumstances when that type alias was used in a parameter or return type annotation.

Page 16 of 81

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.