Pyright

Latest version: v1.1.390

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

Scan your dependencies

Page 47 of 81

1.1.119

Bug Fix: Fixed bug in type evaluator that caused some diagnostics to be suppressed unintentionally and in a non-deterministic manner (based on the order in which types were evaluated).

Enhancement: Added a heuristic to disable the "implied else" analysis if the code is within a function that has no input parameter annotations. This mitigates the performance overhead of "implied else narrowing".

Enhancement: When a function decorator is applied and the decorator returns a function that has no docstring, copy the docstring from the decorated function.

Enhancement: Changed inference logic for constructors to allow synthesized type for `cls` to retain its generic form when instantiated, so the expression `cls()` will remain generic.

Bug Fix: Fixed false positive "metaclass conflict" error that occurs when the metaclass has an unknown class type in its class hierarchy.

Bug Fix: Fixed bug in type evaluator when dealing with a bound TypeVar. The constraint solver wasn't properly handling the Type[T] statement in all cases.

Bug Fix: Fixed recent regression in CLI where partial stub packages were not applied correctly.

Enhancement: Eliminate duplicate python search paths, eliminating the need to search the same path more than once on every import resolution.

Bug Fix: Fixed crash in logic that handles partial type stub merging. The crash occurs when a search path points to a file (e.g. a zip file) rather than a directory.

Enhancement: Added support in PEP 646 when the unpacked TypeVarTuple is not at the end of the type parameter list. This allows for suffixing when matching type arguments against type parameters and when matching TypeVarTuple parameters in a Callable.

Enhancement: Added better error reporting for reveal_type and reveal_locals calls.

Enhancement: Added file system caching to import resolver for performance reasons.

Bug Fix: Fixed bug in type-printing logic for tuples. When typeCheckingMode is "off", type arguments are supposed to be displayed if they are not all "Any" or "Unknown", but they were omitted always.

Bug Fix: Fixed bug that caused type evaluation behavior that depends on (including, possibly, false positive errors) when evaluating subexpressions within a case statement.

Enhancement (from Pylance): Fix HTML escaping in code blocks.

Behavior Change: Exempt ParamSpec from "single use of TypeVar within function signature" check.

Enhancement: Improved error reporting for ParamSpec misuse.

1.1.118

Bug Fix: Fixed bug in logic that verifies exception type in "raise" statement. It was not properly handling generic types that were bound to BaseException.

New Feature: Add --ignoreexternal CLI flag for use with --verifytypes feature. (Contribution by Vlad Emelianov)

Enhancement: The --verifytypes output now includes file paths in the report. (Contribution by Vlad Emelianov)

Bug FIx: Fixed crash that occurred when a function was declared within a local scope but when the function's symbol was previous declared "global" or "nonlocal" within that scope.

Enhancement (from Pylance): Method and class docstrings now inherit from parent classes if docstrings are missing in child class.

Enhancement (from Pylance): Improved support for partial stubs (where py.typed file includes "partial" as per PEP 561).

Bug Fix: Fixed bug that caused incorrect type evaluation for member access expressions when the member was a descriptor object and the base type was a variable containing a reference to the class.

Bug Fix: Fixed bug in document symbol provider that caused incorrect range to be returned for classes and functions.

Enhancement: Improved tracking of incomplete types (those that have not yet been fully established because of recursive type dependencies within the code flow graph).

New Feature: Added logic for if/elif chains that contain no else clause but completely narrow one or more variables.

Behavior Change: Changed behavior of TypeVar constraint solver to eliminate literal types (widening them to their associated type) when solving for TypeVars, unless a literal type was explicitly provided (e.g. using explicit specialization like `List[Literal[1, 2, 3]]`).

Behavior Change: Changed reportOverlappingOverload to be an error in strict mode.

Bug Fix: Fixed bug in logic that determines whether one callable type can be assigned to another. It wasn't taking into account the positional-only parameter separator (`/`).

Bug Fix: Fixed a bug in conditional type narrowing that narrows based on descriminated member variable types. It was being over aggressive in narrowing in the negative ("else") case when the type of the member was a union of literal types.

Bug Fix: Fixed false positive error that occurred when setting or deleting the member of an object where that member's type is defined by a parent class and is generic but is specialized by a child class.

1.1.117

Enhancement: Extended check that detects redeclared functions and methods to also report redeclared properties within a class.

Bug Fix: Fixed crash in parser that occurs when malformed index expression is parsed.

Enhancement: Improved error message for certain type incompatibilities.

Bug Fix: Fixed bug in logic that determines whether a function type is assignable to another function type. It was not properly handling the case where the destination had a **kwargs parameter and the source had an unmatched keyword parameter.

Enhancement: Added new check to ensure that the type signature of a function with overloads is the superset of all of its overload signatures.

Enhancement: Improved consistency of error messages by standardizing on "incompatible" rather than "not compatible".

Bug Fix: Fixed bug in handling of `type(x)` call that resulted in false positive errors.

Behavior Change: Changed the logic that determines whether a variable assignment is an implicit type alias definition. If there is an explicit type annotation (other than the use of the PEP 612 TypeAlias), it is no longer considered a type alias. This is consistent with the rules mypy uses.

Bug Fix: Fixed a bug in the logic for inferring "cls" parameter that resulted in incorrect type evaluations.

Enhancement: Added check to detect inappropriate use of variables (that are not type aliases) within type annotations.

Bug Fix: Fixed bug in type compatibility logic that permitted a type of `Type[Any]` to be assigned to type `None`.

New Feature: Implemented support for PEP 655: Marking individual TypedDict items as required or potentially-missing. This PEP is still under development, so the spec could change.

1.1.116

Enhancement: Improved type inference logic for tuple expressions that contain unpacked tuples.

Bug Fix: Fixed bug that resulted in unknown types within stubs when a forward reference was made within a type alias definition.

Bug Fix: Fixed bug in bidirectional type inference logic for unpack operator.

Bug Fix: Fixed bug in assignment type narrowing for index expressions. The narrowed type was always evaluated as "None" rather than the assigned type.

Bug Fix: Fixed bug in assignment type narrowing that was triggered when the RHS and LHS were both union types and the RHS contained an `Any`.

Enhancement: Added diagnostic check for a call expression that appears within a type annotation. This was previously not flagged as an error.

Bug Fix: Fixed false negative bug in the "reportOverlappingOverload" diagnostic check. It was not correctly detecting overlapping overloads when one of the parameters in the earlier overload was annotated with at TypeVar.

Bug Fix: Fixed bug in logic that compares the type compatibility of two functions. In particular, if the source function contains a keyword argument and the dest function does not contain a keyword argument of the same name bug contains a **kwargs, the types must match.

Enhancement: Added support for overloaded `__init__` method that annotates the `self` parameter with a generic version of the class being constructed.

Behavior Change: Added a few exemptions for the reportInvalidTypeVarUse check. In particular, constrained TypeVars, bound TypeVars used as type arguments, and any TypeVar used as a type argument to a generic type alias are exempt from this check. There are legitimate uses for all of these cases.

Bug Fix: Fixed recent regression in type assignment check logic that broke certain cases where the destination and source were both unions that contained type variables.

Behavior Change: Changed behavior when evaluating type of symbol within type stubs. Previously forward references were allowed only for class types. Now, forward references are allowed (and no code flow analysis is employed) for all symbols. The new behavior is consistent with mypy's.

Enhancement: Added new diagnostic check for an overloaded function without an implementation within a source (.py) file. Fixed a bug in the diagnostic check for a single overload when an implementation is present.

Bug Fix: Fixed bug in the parsing of "with" statements where the "with item" starts with an open parenthesis.

Enhancement: Added "collections.defaultdict" to the list of classes that does not support runtime subscripting in versions of Python prior to 3.9.

Behavior Change: Changed behavior of type inference for empty list (`[]`) and empty dict (`{}`) expressions. They were previously inferred to be `List[Any]` and `Dict[Any, Any]`, but they are now inferred as `List[Unknown]` and `Dict[Unknown, Unknown]`. This affects strict mode type checking, where partially-unknown types are reported as errors. This change may require some explicit type annotations within strictly-typed code.

1.1.115

Bug Fix: Fixed false positive bug where "class not runtime subscriptable" error was reported even if in a type stub.

New Feature: Implemented command-line switches for pythonplatform and pythonversion. These are overridden by pyrightconfig.json settings.

New Feature: Added support for comments and trailing comments within pyrightconfig.json.

Enhancement: Updated to latest typeshed stubs.

Enhancement (from Pylance): Improve auto-import performance.

Enhancement (from Pylance): Added extra perf tracking.

Bug Fix: Fixed false positive error that incorrectly complained about the use of `Annotated` as a class with no type arguments.

Bug Fix: Fixed false positive error when using bidirectional inference of dictionary expression where the expected type key and/or value types contain literals.

Bug Fix: Fixed bug that resulted in wildcard imports (i.e. imports the form `from x import *`) to import symbols from the target that were not meant to be externally visible. This bug occurred only when the imported module had no `__all__` symbol defined.

Bug Fix: Fixed bug in validation of constrained types in TypeVars. Subtypes of constrained types should be allowed.

1.1.114

Enhancement: Improve source mapper (the code that maps symbols found in stub files to the corresponding code in ".py" files) to handle more cases.

Enhancement: Added diagnostic error for try statement that has no except or finally statement.

New Feature: Added "reportOverlappingOverload" diagnostic rule, splitting out a few checks that were previously in the "reportGeneralTypeIssue" rule. This allows for finer-grained control over these overload checks.

Behavior Change: Added a few additional names that can be used for "cls" parameter without triggering diagnostic. These variants are reasonable and are used within some typeshed stubs.

Enhancement: Added TypeVarTuple definition to typings.pyi stub.

Enhancement: Updated TypeVarTuple logic to detect and report an error when a tuple of unknown length is bound to an unpacked TypeVarTuple. This is illegal according to the latest version of PEP 646.

Enhancement: Special-cased the `__init_subclass__` method in the completion provider so it is offered as a suggestion even though there is no classmethod decorator present. This symbol is unfortunately inconsistent from all other class methods in that it doesn't require a classmethod decorator for some reason.

Behavior Change: Changed logic for attributes marked `ClassVar` to allow writes from an instance of the class as long as the type of the attribute is a descriptor object.

Bug Fix: Fixed a hole in type comparison logic for TypeVars that could have theoretically resulted in incorrect aliasing of types.

Bug Fix: Fixed bug that caused false positive when import statement targeted a symbol that had a nonlocal or global name binding.

Behavior Change: Enhanced method override compatibility logic to allow instance and class methods to pass generic bound types for `self` and `cls`.

New Feature: Added support for ".pth" files (often used for editable installs) when using the "venv" configuration option in pythonconfig.json.

Bug Fix: Fixed bug whereby import symbol “A” in the statement “from . import A” was not considered a public symbol in a py.typed source file, but it should be.

Enhancement: Improved handling of enum classes. If such a class is defined in a ".py" file, variables defined in the class with type annotations but no assignment are now considered instance variables within each enum instance, whereas variables assigned within the enum class are assumed to be members of the enumeration. This is consistent with the way the EnumMeta metaclass works. In stub files, type annotations without assignments are still assumed to be members of the enumeration, since that's the convention used in typeshed and other stubs.

Enhancement: Added check for parameter names when comparing functions. Parameter names that do not begin with an underscore must match in name. This also affects method override checks and protocol matching checks.

Bug Fix: Fix potential infinite recursion in source mapping, crash in doc strings

Page 47 of 81

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.