Pyright

Latest version: v1.1.390

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

Scan your dependencies

Page 42 of 81

1.1.150

Enhancement: Avoid completion suggestions when typing an ellipsis. (Thanks to contribution from Marc Mueller.)

Bug Fix: Fixed false positive errors relating to unions created from a `Type[T]` type.

Bug Fix: Fixed bug that caused class docString not to appear in signature help when invoking constructor for classes with synthesized constructor methods (e.g. dataclass or namedtuple).

Behavior Change: Changed `reportPrivateUsage` diagnostic check to suppress the check when method or attribute comes from a type stub file. It is presumably part of the public interface contract in this case and not a private or protected member.

Enhancement: Added completion suggestion support for dictionary key names.

Bug Fix: Fixed bug in type evaluator that resulted in incorrect type in certain cases when evaluating function with declared return type of `Type[T]`.

Bug Fix: Fixed false positive error that occurred when evaluating a binary operation provided by a metaclass when the LHS or RHS type was a `Type[T]`.

Behavior Change: In basic type checking mode, enabled the following diagnostic checks by default: reportOptionalSubscript, reportOptionalMemberAccess, reportOptionalCall, reportOptionalIterable, reportOptionalContextManager, and reportOptionalOperand.

Bug Fix: Fixed crashing bug in document symbol provider when handling import statements.

Bug Fix: Fixed type evaluation bug that affected the specialization of a generic type alias that includes a bound TypeVar.

1.1.149

Bug Fix (from pylance): Fixed crash that can occur when a library is installed in the form of a zip file, and that zip file is malformed.

Bug Fix: Fixed bug that caused false positive error when using a generic type alias as a constructor call.

Enhancement: Added check for illegal use of "async" keyword. The Python interpreter generates a syntax error if it is used outside of an async function.

Enhancement: Tweaked heuristics in constraint solver for dealing with matching of TypeVar T for the type expression `Union[T, SomeClass[T]]`. There are two valid solutions if the argument is type `SomeClass[X]`, but the "simpler" solution (`T = X`) should be preferred over the more complex (`T = SomeClass[X]`).

Bug Fix: Fixed bug in type checker related to the use of a TypeVar or ParamSpec within an inner function when it is already bound to an outer function but used only within that outer function's return type annotation.

Bug Fix: Added error handling for very large source files. This situation is now detected earlier so we don't attempt to load the file contents and crash the language server in the process.

Behavior Change: Added logic to convert `Type[A | B]` into `Type[A] | Type[B]`, which avoids violating assumptions elsewhere in the type checker.

Enhancement: Updated to the latest version of typeshed, which includes support for ParamSpec in contextlib's contextmanager function.

Bug Fix: Fixed bug in type checker that occurred in some cases when a generic function returned `Type[T]`. In some cases where an input parameter also had an annotation of `Type[T]`, the "solved" type was wrapped in `Type` twice (e.g. `Type[Type[int]]`).

Bug Fix: Fixed bug in type evaluator that occurred when calling a constructor of type `Type[T]` where `T` is a constrained TypeVar.

Bug Fix: Fixed bug that resulted in an import being marked as unaccessed if it was accessed within a class declaration but was also redeclared within the class scope.

1.1.148

Enhancement: Improved type narrowing of subject expression in a match statement when none of the case statements match the pattern and the code falls through the bottom of the match.

Enhancement: Added support for pattern matching exhaustion detection in cases where there is not an explicit irrefutable pattern present.

Bug Fix: Fixed recent regression that resulted in false positive errors when attempting to instantiate `tuple` or `type` directly.

Enhancement: Improved type checking for classes that are assigned to `Callable` types. Previously, type incompatibilities were not reported if the `__init__` or `__new__` methods were overloaded within the class.

Bug Fix: Fixed bug that caused parser error when handling a carriage return within a triple-quoted inner string within an outer triple-quoted f-string.

Bug Fix: Fixed bug that resulted in false positive error when second argument to `NewType` call contained a `Type` object.

Bug Fix: Fixed recent regression that resulted in a false positive error when instantiating a variable of type `Type[T]` where `T` was a protocol class.

Bug Fix: Fixed bug in type printer that resulted in double parentheses around return type expressions when they involved unions.

Bug Fix: Fixed bug that resulted in a false positive error when using generic `Type[T]` in a function parameter in overload validation.

Bug Fix: Fixed bug in type checker relating to constrained type variables that combine non-union and union constraints.

Bug Fix: Fixed bug in type checker when handling Final variables assigned at the class level. PEP 591 indicates that they should be treated as though they are annotated as ClassVar even though they are not.

Bug Fix: Fixed a bug in the type checker relating to the use of a specialized generic class that is parameterized by a ParamSpec.

1.1.147

Enhancement: Added check for an attempt to instantiate a protocol class. This causes a runtime error.

Behavior Change: Closed a hole in type narrowing for "in" operator when used with TypedDict. It can eliminate types from a union only if the type is marked final.

Enhancement: Changed type printer to handle recursion differently — most notably when dealing with recursive type aliases. If it is asked to expand type aliases, it now expands only the first level of a given type alias, so if there's recursion, it will use the type alias name the second time it is encountered rather than continuing to expand it.

Enhancement: Changed `reveal_type` and `reveal_locals` to expand type aliases in their output.

Bug Fix: Fixed bug that resulted in incorrect type checking behavior when a type annotation involved a tuple with literal elements.

Bug Fix: Fixed bug that affected the handling of a function decorator that uses ParamSpec when applied to a classmethod or staticmethod.

Enhancement: Added diagnostic for an attempt to instantiate a special type like a Union, Callable, or Optional.

Bug Fix: Improved support for generic functions that annotate a parameter and a return type with a union that includes a TypeVar. In such cases, the TypeVar may not be matched during constraint solving.

Enhancement: Improved hover text for type variables and param specs by updating the label so they are not shown simply as type aliases.

Enhancement: Updated to the latest typeshed stubs.

1.1.146

Enhancement: Updated to the latest version of typeshed stubs.

Behavior Change: Updated `reportIncompatibleVariableOverride` to avoid reporting an error when a class variable is reassigned a value in a base class without declaring its type.

Bug Fix: Fixed false positive error indicating that a type alias is a variable. This results when a type alias refers to a union and that union is reformed when losing the original type alias.

Enhancement: Added optimization for union creation where all subtypes are the same. This optimization commonly reduces the need to create new types during code flow operations. It also retains type alias info more faithfully.

Enhancement: Added support for `__qualname__` and `__module__` attributes within a class body.

Behavior Change: Changed call expression evaluation logic to not skip return type inference when there are errors detected during argument expression evaluation. This was previously added as an optimization, but it was leading to confusing results in some cases.

Enhancement: Enhanced logic to detect unannotated decorator functions and treat them as no-ops rather than using return type inference, which often leads to incorrect and confusing results for decorators.

Bug Fix: Fixed bug in pattern matching logic for class patterns where the class uses properties or descriptors for the targeted attributes.

Enhancement (from pylance): Added support for libraries packages as zip/egg containers.

1.1.145

Bug Fix: Fixed bug that resulted in the incorrect type when bidirectional type inference (an "expected type") was used in conjunction with the `tuple()` constructor.

Behavior Change: Changed logic to avoid reanalyzing a file when it is opened in the editor if we have already analyzed it and the file contents are the same as before.

Bug Fix: Improved handling of call expressions where the call is a union and some of the subtypes return NoReturn and others do not.

Behavior Change: Changed the logic that validates the assignment to instance variables that are marked `Final`. Previously, only one such assignment was allowed even if it was within an `__init__` method. It now allows an arbitrary number of assignments (conditional or otherwise) as long as they occur within an `__init__` method.

Enhancement: Enhanced "reportIncompatibleVariableOverride" diagnostic check to detect the case where a base class declares a class variable and a child class tries to override it with an instance variable or vice versa.

Bug Fix: Added logic to handle the case where a dataclass subclass overrides a member of its parent class with a ClassVar and another dataclass then subclasses from the child.

Enhancement: Enhanced type stub generator so it doesn't emit "object" as base class, since that's implied in Python 3.x.

Enhancement: Enhanced type stub generator to emit inferred function and method return types as comments.

Behavior Change: Removed false positive error reported for a "bare" `raise` statement outside of an `except` clause.

Bug Fix: Changed type variable constraint solver to preserve literal types when matching type arguments from other class types. In other cases, it typically "strips" the literal, widening the type to a str, int, etc. This change allows proper type evaluation in certain cases where a literal type is specified in a type annotation, such as with `Set[Literal["foo"]]`.

Bug Fix: Fixed bug in code flow engine where it was sometimes evaluating the wrong type when cycles occurred in type dependencies.

Bug Fix: Fixed bug that can result in a crash when indexing a file that includes a nested function or lambda that is used for type inference.

Enhancement: Improved detection and reporting of illegal type alias recursion cases — e.g. when a possible type alias refers to a function that uses the type alias in parameter or return type annotations.

Enhancement: Changed type printer to include a "*" after a type if it is conditionally associated with a TypeVar constraint.

Bug Fix: Augmented type checking logic for generator expressions to allow `await` keyword even though enclosing function isn't async. Also allowed generator expression to be evaluated as `AsyncGenerator` rather normal `Generator`.

Enhancement: Changed the way conditional constraints are tracked in the type evaluator. This is a significant change that simplifies the logic and handles some cases that the old approach did not.

Page 42 of 81

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.