Pyright

Latest version: v1.1.390

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

Scan your dependencies

Page 11 of 81

1.1.333

Bug Fix: Fixed a bug that resulted in a false negative when assigning one TypedDict to another TypedDict. Field types should be treated as invariant rather than covariant because they are mutable (unless marked readonly).

Enhancement: Improved the synthesized `update` method for `TypedDict` classes so it supports keyword arguments and iterables of tuples.

Bug Fix: Improved error message for protocol mismatch when a method in the source cannot be bound.

Performance: Added performance improvement that speeds up type checking for TypedDict classes that have a large number of entries.

Bug Fix: Fixed a bug that led to a false positive when doing protocol matching for a protocol that uses deeply nested recursion.

Bug Fix: Fixed a bug that resulted in incorrect narrowing on assignment when the assigned type is a tuple that includes one or more `Any` type arguments and the declared type is a tuple without an `Any`.

Bug Fix: Fixed a bug that led to a false positive error when doing protocol matching for a protocol and implementation that use a combination of class-scoped and function-scoped TypeVars.

Bug Fix: Fixed several bugs in `ReadOnly` TypedDict functionality based on the latest draft of the PEP 705.

Enhancement: Extended the `len(x) == L` type guard logic to support arbitrary expressions `L` that evaluate to a literal int type.

Behavior Change: Removed support for `readonly` keyword parameter for `TypedDict` to reflect latest changes in PEP 705.

Bug Fix: Fixed bug in protocol matching when source is a namedtuple or a frozen dataclass. Algorithm wasn't taking into account that attributes in these classes are immutable.

1.1.332

Bug Fix: Fixed crash that occurs when encountering a malformed system version check of the form `sys.version_info[0] < 3.8`.

Enhancement: Improved error message for `yield` statements when the yield type is a TypedDict or other type that requires bidirectional type inference.

Bug Fix: Fixed regression in `type(x) is y` type narrowing logic when `y` is of type `type[Self]`.

Bug Fix: Fixed a bug in protocol matching logic that resulted in a false positive error when a class implementation used a callback protocol rather than a `def` statement to define an instance variable defined in a protocol.

Bug Fix: Fixed a bug that resulted in an unresolved `Unknown` type within a tuple constructed within a loop.

Bug Fix: Fixed several bugs in protocol matching that led to false positives when matching a protocol against a module.

Behavior Change: Changed type evaluation behavior for accesses to attributes on a class that derives from `Any`. Previously, these were evaluated as `Unknown`, but they are now evaluated as `Any`.

Bug Fix: Fixed a bug in the `reportIncompatibleMethodOverride` check that leads to a false negative if the base class uses a `Self` type and the override uses an incompatible specialized type.

Enhancement: Added logic to detect illegal use of the symbol `Any`.

Enhancement: Added logic to perform basic reformatting (especially dedenting) of deprecation messages used with `deprecated`.

Bug Fix: Fixed a bug in the isinstance type guard logic when the specified filter class (the second argument) is a metaclass (a subclass of `type`).

Bug Fix: Fixed a bug in the `issubclass` type narrowing logic when the first argument is a metaclass (a subclass of `type`).

Enhancement: Updated typeshed stubs to the latest version.

Behavior Change: Changed override-related checks (`reportIncompatibleMethodOverride`, `reportIncompatibleVariableOverride` and `reportImplicitOverride`) so they apply to stub files. Previously, these were skipped for stubs.

Bug Fix: Fixed a bug that caused types captured by ParamSpecs to sometimes be printed with `Unknown` parameter types.

Bug Fix: Fixed a bug in ParamSpec type matching that resulted in an incorrect type evaluation under certain circumstances.

Bug Fix: Fixed a regression in overload matching that resulted in false positive errors in hydra-zen. This change involves removing a heuristic from overload matching that attempted to eliminate a false positive error for `x: list[str] = "a,b".split(",")`.

Bug Fix: Fixed a bug that results in confusing error messages when converting a constructor (an `__init__` method) to a function type. The resulting function should not be named `__init__` but should be anonymous.

Bug Fix: Fixed a bug that led to a false positive error when a type alias created using PEP 695 syntax is used as a type argument for a generic type when used in the LHS of a call expression.

Bug Fix: Fixed a bug in the `isinstance` type narrowing logic when using a generic class whose type parameters include defaults (PEP 696).

Bug Fix: Fixed a false positive error "TypeVar bound cannot be generic" if the bound type is a generic class whose type parameters have default types (using PEP 696).

Bug Fix: Fixed bug in "type printer", the code that converts a type to text for error messages. It wasn't properly handling `type(t)` where `t` is defined using a type alias.

Enhancement: Improved the error message for metaclass conflicts so the conflicting metaclasses are specified.

Bug Fix: Fixed a bug in the type narrowing logic for sequence patterns, specifically when the subject is `Any` or `Unknown` and the sequence pattern is empty (`[]`).

Bug Fix: Fixed a bug with path normalization (in particular, drive letter) for symbolic links that resulted in false positive errors.

Bug Fix: Fixed a bug that led to a false positive error when attempting to instantiate a value of type `type[Self]` when `Self` refers to an abstract class.

Bug Fix: Fixed a bug that led to a false positive error when passing `type(None)` or `NoneType` as the second argument to `issubclass`.

Bug Fix: Fixed a bug in the `issubclass` type narrowing logic for `type(None)` and `NoneType` filters.

Bug Fix: Fixed a bug that led to a stack overflow crash under certain circumstances when evaluating a function call with a ParamSpec.

Bug Fix: Fixed bug that prevented `ReadOnly` experimental feature from being used in a file where a ` pyright: enableExperimentalFeatures=True` comment was used.

1.1.331

Bug Fix: Fixed a bug that led to a false positive error and incorrect type evaluation under certain circumstances when multiple symbols depend on each other in a loop.

Bug Fix: Fixed a recent regression that led to a false positive error when a class uses a custom metaclass that supplies a `__setattr__` method.

Enhancement: Improved type narrowing in the negative case for `isinstance` when the filter type (the second argument) is `type[T]` (where `T` is a type variable) and the first argument is of type `T`. In this case, we can eliminate (filter) `T` in the negative case.

Bug Fix: Fixed a bug that led to a false positive error when using a zero-argument `super()` call within a class declaration within a method body.

Enhancement: Added support for deprecated when applied to property accessors and descriptor methods.

Bug Fix: Fixed a bug that led to a false positive error when doing protocol matching with a protocol class that has a method with method-scoped type variables.

Enhancement: Added missing check for the use of a subscripted `Callable` within an `isinstance` call.

Bug Fix: Fixed bug that led to incorrect type narrowing for `isinstance` when using `Callable` and the pre-narrowed type is `object`.

Bug Fix: Fixed a bug that led to incorrect type evaluation in a nested set of call expressions and a lambda.

Bug Fix: Fixed a bug that led to a confusing error message when assigning a value with an incompatible type to a class variable that has no explicit type declaration.

Bug Fix: Fixed bug in `x is <Literal>` and `x == <Literal>` type guard logic. It was not properly handling the case where `x` is `Any` or `Unknown`.

Bug Fix: Fixed a bug that led to incorrect type narrowing in the `type(x) is T` and `type(x) == T` type guards when `T` is a dynamic type rather than a specific class.

Enhancement: Improved completion provider logic for `__getitem__` methods with literal types. The old logic didn't properly handle generics or overloads.

Enhancement: Don't show `stubPath xxx is not a valid directory` warning in logs when using config default.

1.1.330.post0

1.1.330

Bug Fix: Fixed a bug in the diagnostic filtering logic that caused the grayed-out "unused symbol" treatment to be suppressed when using a ` pyright: ignore` comment. This comment is intended to apply only to real diagnostics (errors, warnings, infos), not hints with tags.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when accessing an attribute on a class whose metaclass defines a `__getattr__` method and the target attribute is a descriptor object.

Bug Fix: Fixed a crash that can occur if a type annotation includes too many type arguments for a class.

Bug Fix: Fixed a regression that resulted in a false positive error when using `float` or `complex` literals or constructor calls and then accessing a member of the resulting object that is valid on that class but not on `int`.

Bug Fix: Fixed a recent regression in the overload matching behavior that broke two tests in the pandas-stubs test suite.

Bug Fix: Fixed a bug that resulted in a false positive in certain circumstances where a lambda included simple math operations with integer literals. The fix requires disabling literal math within lambdas, since they are often used as callbacks that are called repeatedly in a loop.

Bug Fix: Reverted a portion of the recent changes designed to differentiate between a `float` that is really a `float` or a `float` that can also be an `int`. This resulted in false positives when inferring types using float literals.

Bug Fix: Fixed a false positive due to incorrect type narrowing logic when a `del` statement targets a specific element within a list (e.g. `del my_list[1]`).

Bug Fix: Fixed a crash due to an invalid assert that occurs when a class or function that uses PEP 695 syntax is unreachable.

Bug Fix: Fixed a bug that led to incorrect type evaluation and false positives when constructing a specialized generic TypedDict.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Improved the check for whether an object is "awaitable". Rather than hard-coding checks for `__await__` and `__init__` methods, use the `typing.Awaitable` protocol.

Bug Fix: Fixed a false positive `reportInvalidStringEscapeSequence` error if a string literal is over 32K in length and the 32768'th character is a backslash.

Enhancement: Added support for PEP 692 (unpacked TypedDict for `**kwargs`) when used with a `ParamSpec`.

Bug Fix: Fixed a bug that led to the loss of type narrowing for a captured variable used within an inner scope if used in a comprehension expression.

Behavior Change: Changed the default Python version (the version that is assumed by pyright if it has no other context) from 3.11 to 3.12 now that 3.12 is final.

Enhancement: Improved diagnostic for the situation where overload matching fails to find any applicable overloads.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when an async function with an inferred return type is decorated with a class or function that uses a ParamSpec (such as `functools.wraps`).

Bug Fix: Fixed a bug that led to a false positive error when using a single-quote form of a format string that uses a format specifier expression. This is also a bug in the Python 3.12 interpreter that is being fixed.

1.1.329

Behavior Change: Added new configuration switch `disableBytesTypePromotions` that is off by default except in strict mode, when it's on by default. When enabled, it eliminates the old (poorly-documented) behavior whereby `bytes` when used in a type annotation automatically implies the union `bytes | bytearray | memoryview`. For details, refer to [PEP 688](https://peps.python.org/pep-0688/). The configuration switch allows code bases to retain the old behavior, but it's likely that the default value of this option will change to true in the future.

Behavior Change: Improved handling of types `float` and `complex`, which are special-cased in PEP 484 as "promotion types". The new logic now properly models the runtime behavior for `isinstance` and class pattern matching when used with these promotion types.

Behavior Change: Added check for the use of an ellipsis for a default argument value for a function that is not in a stub, not overloaded, and without a placeholder implementation.

Bug Fix: Fixed false positive error that occurs when a member of a frozen dataclass is overridden in a subclass. In this case, the type should not be considered invariant because the field isn't mutable.

Bug Fix (from pylance): Fixed recent regression that caused import resolution issues when using UNC paths and symlinks.

Bug Fix: Fixed several issues with logic that performs protocol matching against a module, including a false positive error when matching against a generic protocol.

Bug Fix: Fixed bug in type compatibility checks for `LiteralString`. It should not be considered compatible with `str` or a specific literal str in an invariant context.

Bug Fix: Fixed a false positive error with the `reportUnnecessaryComparison` check when a recursive type alias is used.

Bug Fix: Fixed a bug in the handling of `__match_args__` in class pattern matching. Pyright was using the subject's class rather than the pattern's class to look up `__match_args__`.

Bug Fix: Fixed a bug in the handling of class pattern matching for subclasses of `int`, `str` or other stdlib classes that implicitly supply `__match_args__` and return `self` for matches.

Enhancement: Added a check for class pattern matches where the number of positional patterns exceeds the number of positional fields supported by the class.

Enhancement: Improved error message for type compatibility for `list` and `dict` types, which enforce invariance. The new error message now suggest the use of `Sequence` and `Mapping`, respectively.

Page 11 of 81

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.