Pyright

Latest version: v1.1.390

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

Scan your dependencies

Page 34 of 81

1.1.198

Enhancement: Added support for exception group syntax introduced in PEP 654.

Bug Fix: Fixed bug that resulted in false positive errors when using a TypeVar within the new callable syntax within a function declaration.

Enhancement: Added missing check mandated by PEP 544, which disallows an assignment of a class type to a Type[Proto] if the class type is a protocol itself.

Enhancement: Added support for class types that satisfy protocols. This is specifically allowed in PEP 544 in the section titled "Type[] and class objects vs protocols".

Enhancement: Added support for assigning a param spec to a `...` signature, since the latter is the `Any` equivalent for ParamSpecs.

Behavior Change: Changed type logic to allow `type` to be assigned to `Type[T]`. In this case, `type` is treated the same as `Type[Any]`, so `T` receives a value of `Any`.

Enhancement: Added support for `__getattr__` and `__getattribute__` overloads that are typed with a literal str representing the attribute name.

Bug Fix: Fixed bug in handling of callable syntax when a TypeVar, ParamSpec or TypeVarTuple was used outside of an appropriate scope. No error was emitted in this case.

Bug Fix: Fixed a bug in the handling of the new callable syntax when it's used with an "async" keyword. The resulting return type should be `Awaitable` rather than `Coroutine`.

Behavior Change: Changed the behavior of the new callable syntax to not accept `...` with other parameters. After further discussion on the typing-sig, the consensus is that supporting this will cause confusion.

Bug Fix: Fixed a false negative (missing) error when a method within a generic class was annotated to return a generic type of itself.

Enhancement: Added logic to handle the case where a declared return type of a function includes a constrained TypeVar and a return statement is guarded by a conditional check that guarantees that the constraint is met on that code path.

Enhancement: Improved error message (and reduced cascading errors) for the case where a variable is incorrectly used as the LHS of a subscript expression within a type annotation.

1.1.197

Bug Fix: Fixed bug in type narrowing code for literal enums. It wasn't correctly handling the edge case where the enum class has no enumerated members.

Bug Fix: Fixed bug in type narrowing logic for comparisons to literals that involve enums declared in a type stub. It was incorrectly narrowing the type to `Never` in the negative (else) case.

Bug Fix: Fixed bug in type evaluator that resulted in incomplete (Unknown) types when variable types depend on each other within a loop and one of the expressions involves an unpack operator.

Bug Fix: Fixed bug in protocol TypeVar variance validation. Thanks to Azureblade3808 for this contribution.

Enhancement: Added support for ellipsis type argument for a generic alias that uses a ParamSpec.

Bug Fix: Fixed bug that caused false positives when assigning a function to a generic class or callback protocol that is parameterized with a ParamSpec that is specialized using an ellipsis.

Bug Fix: Fixed several bugs where `Type[None]` was incorrectly treated as compatible with `None` and vice versa.

Bug Fix: Fixed bug that resulted in a false positive error when `Required` or `NotRequired` special forms were used with no type arguments in contexts where they are used as runtime class names rather than type annotations.

Behavior Change: Changed text representation of callables to more closely match the syntax introduced in PEP 677 including the use of "..." to represent "any parameters" and "**P" to represent a ParamSpec.

Bug Fix: Fixed error in pyrightconfig JSON schema, which duplicated a couple of IDs.

Bug Fix: Fixed bug that caused crash in type analyzer when a TypeVar of the same name was declared twice in the same scope with constraints in one case and without in the other.

Enhancement: Added support for draft PEP 677: callable type syntax.

1.1.196

Enhancement: Added support for Python 3.11 StrEnum.

Behavior Change: Modified behavior for assignment-based type narrowing when the target of the assignment references an "asymmetric" descriptor or property, one where the setter accepts a different value type than the getter returns. When this is detected, assignment-based type narrowing is no longer applied.

Behavior Change: Changed class pattern matching behavior to support narrowing of `Any` or `Unknown`, exempting this case from the general "never narrow Any" rule.

Behavior Change: Modified behavior of overload matching when unpacked argument is present and the unpacked iterator is a type that doesn't provide any length information. In this case, overload matching will prefer an overload that includes a `*args` parameter rather than individual positional parameters.

Enhancement: Added check for a module used as a type annotation, which is not permitted.

Enhancement: Improved `isinstance` type narrowing logic to retain type arguments in cases where the corresponding type parameter is bound or constrained.

Bug Fix: Fixed bug that resulted in a false positive error indicating that an overload isn't compatible with its implementation when the overload includes a callable parameter with a type variable as a parameter.

Bug Fix: Fixed a bug in type evaluation of a `Final` class variable that has no explicit type but is assigned a literal value.

Bug Fix: Fixed a bug that resulted in incorrect type evaluations when a generic class using a ParamSpec was explicitly specialized using a `Concatenate` in the type argument, as in `A[Concatenate[int, P]]`.

Bug Fix: Fixed a bug that resulted in incorrect type resolution when evaluating mutually-dependent variables within a loop where one of the expressions involved a call to a constructor with an unpacked argument.

Bug Fix: Fixed false positive error with reportUnnecessaryIsInstance diagnostic check with the provided class is dynamic.

1.1.195

Bug Fix: Fixed bug in handling of `__slots__`. Entries listed in `__slots__` apply only to instance variables, not to class variables.

Bug Fix: Fixed false positive error with reportUnnecessaryComparison diagnostic rule when one of the two operands is `type` or `Type[Any]` and the other is a class.

Bug Fix: Fixed false positive when using a generic type alias that refers to a class with a `__getitem__` method.

Enhancement: Implemented support for type guards that based on "aliased conditional expressions". For details and examples, refer to https://github.com/microsoft/pyright/blob/main/docs/type-concepts.md#aliased-conditional-expression.

Bug Fix: Fixed a bug that caused a false positive error under certain circumstances where a function return type annotation referred to a forward-declared symbol and `from __future__ import annotations` was in effect.

Enhancement: Added error for an attempt to call a module, which generates an exception at runtime.

Bug Fix: Fixed bug related to ParamSpec specialization when the signature has zero parameters.

Behavior Change: Changed type completeness report (the "--verifytypes" feature) to exempt symbols that derive from "__slots__" entries.

Enhancement: Improved `isinstance` type narrowing when the original type is a generic class with a TypeVar as a type argument and the second argument to `isinstance` is a generic subclass of the original type. The type argument is now properly retained.

1.1.194

Bug Fix: Fixed inconsistency in definition provider where it would sometimes fail to go to a declaration if the symbol was not re-exported from a type stub or "py.typed" module.

Enhancement: Added support for explicit specialization of generic type aliases that include a ParamSpec.

Bug Fix: Fixed bug that resulted in the import resolution paths retrieved from the currently-selected Python interpreter to omit the working directory if it happens to be in the "sys.path" list.

Bug Fix: Fixed bug in specialization of callable type where the return type includes the expansion (unpacking) of a variadic type variable.

Enhancement: Improved handling of `x in y` type guard to handle the case where `y` is a tuple.

Bug Fix: Fixed a bug that caused type narrowing to fail in certain cases when the "X in Y" type guard pattern was used.

Bug Fix: Fixed bug that resulted in false positive when a variable was modified in a loop that employed conditional type narrowing and was also used as a member access expression.

Bug Fix: Fixed a bug whereby an explicit TypeAlias definition that includes a generic type with no explicit type arguments was not assuming `Unknown` for those type arguments. For example, `A: TypeAlias = list` should assume that `A` is equivalent to `list[Unknown]`.

Enhancement: Added a missing diagnostic for an attempt to specialize a class that has already been specialized. This can occur in the case of a type alias, such as `A = list[int], A[int]`.

Enhancement: Added code to support `__qualname__` in class definitions.

Bug Fix: PEP 484 indicates that `Type[Any]` should be interpreted as equivalent to `type`, but the previous code was treating it as `Any`.

Enhancement: Added error check for the use of a generic class as a metaclass.

Bug Fix: Fixed a bug that resulted in a false positive error when a dictionary literal was passed to a constructor of a generic subclass of dict.

1.1.193

Bug Fix: Fixed incorrect type evaluation for symbols that are modified within a context manager block that is nested within a try/except statement.

Enhancement: Updated to the latest typeshed stubs. Note that type stubs for several third-party packages were recently removed from typeshed: click, flask, jinja2, markupsafe, werkzeug.

Bug Fix: Fixed bug that resulted in "unknown" type evaluation for variables assigned in a loop using a tuple assignment pattern.

Bug Fix: Fixed bug in TypeVar solver where Self type was being incorrectly replaced with its concrete form in some cases.

Bug Fix: Fixed bug that resulted in TypeVar not being solved in some circumstances involving recursive types.

Bug Fix: Fixed a bug in the handling of generic classes whose implementation includes another instantiation of itself using the original type parameters as type arguments for the nested instantiation.

Bug Fix: Fixed a bug in the handling of generic classes whose implementation includes another instantiation of itself using the original type parameters as type arguments for the nested instantiation.

Enhancement: Enhanced reportIncompatibleMethodOverride diagnostic check to also detect incompatible methods defined by two classes that are used as base classes in a multiple-inheritance derived class.

Page 34 of 81

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.