pyright

Static Type Checker for Python

OTHER License

Downloads
2.3M
Stars
13.2K
Committers
119

Bot releases are visible (Hide)

pyright - Published 1.1.342

Published by github-actions[bot] 10 months ago

Bug Fixes:

  • Fixed @deprecated functionality that was broken by a recent change to the typeshed stubs (which replaced a function with a class).
  • Fixed bug that results in a false positive error under certain circumstances when calling an inner function that uses a ParamSpec defined scoped to an outer function.
  • Fixed a bug in the --verifytypes CLI feature that resulted in a false negative when docstrings are missing from a class or function that is defined in a private module but re-exported from a public module.
  • Fixed a bug that led to a combinatoric explosion and an infinite loop in certain edge cases involving a class with an untyped constructor and methods that return recursive types.
  • Fixed a bug that led to false negative errors when doing protocol matching with a method that uses Self in its signature.
  • Increased internal limit of the number of overload signatures that can be captured by a ParamSpec from 64 to 1024.
  • Fixed a bug that leads to infinite recursion (stack overflow) under certain circumstances.

Enhancements:

  • Added narrowing support for literal patterns in a match statement that are used to discriminate between tagged unions of objects that can be discriminated based on a field with a literal type.
pyright - Published 1.1.341

Published by github-actions[bot] 10 months ago

Normally, new pyright releases are published each Tuesday. This is an out-of-cycle release that addresses several regressions introduced in 1.1.340. These were all related to a massive change (one that affected a majority of the source files in pyright) that changed the way that file paths were tracked internally. Pyright now uses URIs rather than simple paths — a change that's needed to support a number of language server features.

Bug Fixes:

  • Fixed regression introduced in 1.1.340 that caused a crash in the --verifytypes functionality.
  • Fixed regression introduced in 1.1.340 that resulted in an incorrect URI returned as part of a language server "rename" request.
  • Fixed regression introduced in 1.1.340 that resulted in an unintended schema change for the outputjson output.
  • Fixed regression introduced in 1.1.340 that resulted in a crash when using file watchers (--watch option).
  • Fixed regression introduced in 1.1.340 that resulted in incorrect import resolution for certain namespace packages.
  • Fixed bug that resulted in a false positive error when one ParamSpec was captured by another ParamSpec.
  • Fixed bug related to function type compatibility when the dest type contains an unpacked tuple followed by one or more positional-only parameters as in Callable[[*Ts, int], None].

Enhancements:

  • Improved signature help provider so it handles overloaded __init__ and __new__ methods when calling a constructor.
  • Updated typeshed stubs to the latest version.
pyright - Published 1.1.340

Published by github-actions[bot] 10 months ago

Bug Fixes:

  • Fixed English text for position-only error. It contained an extraneous \" at the end.
  • Fixed a bug that resulted in a crash under certain circumstances when defining a type alias using a type statement when no type parameters are defined.
  • Fixed bug in narrowing logic for sequence pattern magic where special cases of str, bytes, and bytearray were not handled correctly.
  • Fixed bug that led to a false positive when a zero-argument form of super is called within an inner function or lambda.
  • Fixed a bug that led to a false positive error in certain cases involving a union of two callables.
  • Removed implicit __qualname__ attribute from the module namespace. It doesn't exist at runtime, so this was leading to a false negative.
  • Fixed bug that led to a false positive when a tuple of indeterminate length was used in a callback function.
  • Fixed a bug that led to an improper "unbound" type evaluation under certain circumstances in a finally clause.
  • Fixed bug that results in an extraneous } character in stub output.
  • Fixed bug that led to incorrect return type inference for a generator that always raises an exception rather than returning.
  • Fixed package manifest so default values of configurations are properly reflected.

Behavior Changes:

  • (From pylance) All paths are now internally tracked as URIs. This provides better support for files that are not stored within a file system. This should be transparent to most pyright users.
  • Previously, return type inference was disabled for all functions when analyzeUnannotatedFunctions was set to false regardless of whether the function had input type annotations. Return type inference is now enabled if the function is partially annotated.

Enhancements:

  • Improved error message for set invariance type violations.
  • Added support for the @warning.deprecated (PEP 702) functionality when an overloaded function implementation is marked deprecated and then used outside of a call expression.
  • Enhanced type narrowing logic for sequence pattern matching to support narrowing of tuple subject types based on sequence subpatterns.
  • Extended support for "partially unbound" variable detection to cases that involve comprehension and class scopes.
  • Eliminated the limitation that unpack operators, await operators, assignment expressions (walrus operators), f-strings, chained strings, and strings with escape characters cannot be used within Annotated expressions when using an alias of Annotated.
pyright - Published 1.1.339

Published by github-actions[bot] 11 months ago

Bug Fixes:

  • Fixed a bug that resulted in a false positive error under certain circumstances involving inferred variance, decorators and generic type aliases.
  • Fixed a bug that resulted in a false positive when Self was used in a value expression outside of a class body.
  • Fixed bug that resulted in a false positive error when overriding a TypedDict field when the overridden type was Any or vice versa.
  • Fixed bug that resulted in a false negative when overriding a TypedDict field with an incompatible Required or NotRequired attribute.
  • Fixed recent regression that resulted in a false negative when type or type[Any] was used as a type annotation for a field in a dataclass.
  • Fixed a bug that results in a false positive when anext is passed a value of type AsyncIterator.
  • Fixed recent regression that results in false positive error where type or type[Any] is not considered type compatible with Callable.
  • Fixed bug that affected the case where a TypedDict class derived from two incompatible classes using multiple inheritance. The error was reported in the wrong location.
  • Fixed bug that results in incorrect type evaluation when a raise statement is used within a context manager that swallows exceptions.
  • Fixed bug that led to incorrect type evaluation with unary operator when used with a type alias defined with forward references.
  • Fixed bug that resulted in a crash within the function return type checking logic.
  • Fixed bug that resulted in incorrect type evaluation when del statement is applied to a class member implemented with a descriptor.
  • Fixed regression that resulted in a false negative for the reportUnknownMemberType check when the expression is a call argument and the member is a function with a partially-unknown signature.
  • Fixed a bug that resulted in incorrect type evaluation in certain cases involving generic protocols and bound TypeVars.
  • Fixed a bug in the code flow engine that resulted in a false negative for a variable whose type is narrowed within an inner loop.
  • Fixed bug that led to improper type narrowing for class patterns when Callable is used.
  • Fixed bug that resulted in incorrect narrowed type evaluation in certain circumstances involving certain code flow graph structures.

Enhancements:

  • Added support in dataclass_transform for custom field specifiers that have default arguments for their init or kw_only parameters.
  • Implemented check for inconsistent use of @staticmethod and @classmethod in overloads.
  • Added support for accessing members of a TypeAliasType object.
  • Added an error check for a PEP 695 type statement within a function body. Type alias definitions are not allowed within this scope.
  • Added support for *args: *Ts parameter that captures a callable with an indeterminate number of positional parameters because some of them have default arguments.
  • (Contribution from @jbarrachinab) Improved a few error messages in the Spanish localization.
  • Enhanced support for TypeVarTuple capture of a callable to support literal arguments.
  • Added a few optimizations that help improve perf somewhat when large unions are involved.
  • Added support for doc strings when using the PEP 695 type statement.

Behavior Changes:

  • Added a new typeCheckingMode called "standard". It's a subset of "strict" but a superset of "basic". It is the new default mode, and it should cover all of the required checks for conformance with the Python typing standard.
  • Changed behavior of check for unimplemented methods in a class that explicitly derives from a protocol. If the class also explicitly derives from abc.ABC, it is exempted from this check. This is useful for mixin classes.
  • Changed behavior of reportUnknownMemberType (and other checks in the reportUnknown... family) to not report a partially-unknown type if it refers to an unspecialized class.
  • Moved checks for Required/NotRequired and ReadOnly overrides from reportGeneralTypeIssue to reportIncompatibleVariableOverride for consistency. Added checks for Required/NotRequired and Readonly incompatibilities in the multiple inheritance case.
  • Changed behavior of two-argument form of super when it is used outside of an attribute access expression. It now employs a heuristic whereby it evaluates to the next base class of the bound type.
  • Changed the type printer logic to avoid emitting truncated Literal string and bytes values when it is asked to enforce Python syntax. This mode is used for inlay hints and the stub generator (for inferred return type comments).
pyright - Published 1.1.338

Published by github-actions[bot] 11 months ago

Bug Fixes:

  • Fixed a bug that results in a false positive error in the reportUnknownMemberType check when abc.Callable (without any type arguments) is used in the second argument to an isinstance call.
  • Fixed bug in literal pattern matching that resulted in incorrect narrowing when the subject was typed with a constrained TypeVar.
  • Fixed bug that led to incorrect conversion from a class constructor to a function when it involves a __new__ method that returns Self.
  • Fixed bug that resulted in crash under certain obscure circumstances where a class with multiple type parameters is explicitly specialized with only a subset of required type arguments.
  • Eliminated some differences between the treatment of type and Type. These should be treated the same under all circumstances.
  • Fixed recent regression that resulted in a false positive when accessing a class property from a class instance.
  • Fixed a bug that can result in spurious false positive errors when using deeply-nested or recursive type definitions such as _NestedSequence in numpy.
  • Fixed bug that led to a false negative when Never is used as an explicit type argument for a generic class or type alias if the corresponding type parameter is a constrained TypeVar.
  • Fixed bug that produces a false negative when attempting to assign a method to a Callable type where the first parameter of the method is typed as Self, but the callback requires the class itself.
  • (from Pylance) Fixed bug that led to false positive errors related to import resolution when a partial stub is used and its directory structure doesn't match that of the library.

Enhancements:

  • Improved error handling for failures when explicitly specializing a generic type alias. Improved diagnostic message for assert_type failures when printed types look the same when not using the full name of the type.
  • Added support for bidirectional type inference for chained assignment expressions.
  • Updated typeshed stubs to the latest version.
  • Added deprecation message for class properties, which were deprecated in Python 3.11 and are going away in Python 3.13.
  • Added support for parameter type inference for lambdas whose parameters include default arguments. This is analogous to the logic used for unannotated function parameters with default arguments.

Behavior Changes:

  • Changed the behavior for empty dict or list expressions. Previously, a variable initialized with {} or [] was not flagged as "partially unknown" by the reportUnknownArgument check when used as an argument to a call. This resulted in a small type hole.
  • Changed type evaluation logic for member access expressions for type[Any] where the target attribute is not explicitly declared in the type or object class. Previously, pyright emitted an error in this case.
pyright - Published 1.1.337

Published by github-actions[bot] 11 months ago

Bug Fixes:

  • Fixed a bug that resulted in a false positive when applying a descriptor whose __get__ method whose owner parameter is annotated with type[T].
  • Fixed bug that affected the isinstance type narrowing logic when the pre-narrowed type is a type alias that refers to a union that includes a recursive type alias.
  • Fixed bug in completion provider that resulted in incorrect keyword parameter suggestions for positional-only parameters.
  • Fixed bug that led to a spurious "unknown argument type" when passing an unpacked tuple in a call expression.
  • Fixed regression that results in a false positive when using a value of type type[Protocol] as the second argument to isinstance or issubclass if the protocol isn't @runtime_checkable.
  • Fixed regression that resulted in false positive errors when a magic method (e.g. __lt__ or __add__) are implemented with a callable protocol object.
  • Fixed a bug that resulted in a false positive error when using a walrus operator in a call expression that targets an overloaded function.
  • Fixed bug that led to a hang (infinite loop) in the language server when opening a document whose URI wasn't a "file". This occurred in some language servers that used an "untitled" (or similar) URI type for new documents.
  • Modified recent bug fix in isinstance and issubclass type narrowing logic so it better handles type variables with bounds that are unions.
  • Fixed a bug that resulted in a false positive error when a higher-order generic function is passed another generic function as an argument along with another argument that dictates the type of the first argument's type variable(s). This shouldn't depend on the order in which the arguments are passed.
  • Fixed a bug that resulted in a false positive error when a higher-order generic function is passed another generic function as an argument along with another argument that dictates the type of the first argument's type variable(s). This shouldn't depend on the order in which the arguments are passed.
  • Fixed a recent regression that resulted in a false positive error when a parent class defines a property with a getter and a child class extends the property with a setter.
  • Fixed bug that led to an incorrect type evaluation when a list comprehension expression is used with bidirectional type inference and the expected type includes a type variable.
  • Fixed bug that led to a false positive error when a __getitem__ returns Self.
  • Fixed a bug that led to a false positive when determining the type compatibility of two TypedDict definitions whose keys were typed with unions that included two other (compatible) TypedDict definitions.
  • Fixed a bug that led to incorrect type evaluation when two lists with different types were concatenated using a + operator in a bidirectional inference context.
  • Fixed a bug that results in incorrect type evaluation of an index expression when the LHS is unbound. It should produce Unknown rather than Never.
  • Fixed bug that resulted in a false positive under certain circumstances where a recursive type alias was used and hit an internal recursion limit.

Enhancements:

  • Improved lambda inference logic to handle the case where the expected type is a callable that accepts a generic callable as a parameter.
  • Added error reporting for illegal use of TypedDict or Protocol within a TypeVar bound or within a type annotation.
  • Enhanced reportInvalidTypeVarUsage diagnostic message to include a recommended fix.
  • Added check for the use of a bare Literal (with no type arguments) in places where it's not allowed.

Behavior Change:

  • Adjusted heuristic for reportInvalidTypeVarUse so it doesn't emit a warning when an unbound TypeVar is used within a subscript.
pyright - Published 1.1.336

Published by github-actions[bot] 11 months ago

Bug Fixes:

  • Fixed bug that results in an incorrect type evaluation when functools.partial is used with a constructor where type[Self] is passed as the first argument.
  • Fixed bug that resulted in a crash during type analysis.
  • Fixed bug that results in false positive when indexing an enum class.
  • Fixed a bug that led to a false positive error when calling the same generic function multiple times in a call expression. This bug specifically affected the case where the generic function used PEP 695 syntax.
  • Fixed a bug that led to a false negative when a subclass overrides a parent class with an overloaded method in an incompatible manner.
  • Fixed bug in the import resolver that allowed typeshed stubs and stub files within installed third-party libraries to take precedence over local modules.
  • Fixed a bug that leads an incorrect type evaluation when binding a magic method (like __add__) to self when the magic method returns Self.
  • Fixed a bug that resulted in an incorrect type evaluation when accessing a property that returns Self or type[Self].
  • Fixed bug that resulted in incorrect type evaluation of a symbol imported twice by two redundant wildcard imports.
  • Fixed a bug that leads to a false positive reportPrivateUsage diagnostic when importing a public symbol from a "py.typed" library if that symbol is imported from a private symbol (and re-exported publicly) within the library.
  • Fixed a bug that led to incorrect type evaluation when an inferred method return type includes a union where the subtypes are conditioned on constraints of a constrained TypeVar that parameterizes the class. In this case, one or more of these subtypes should be eliminated when a specialized class is bound to the method.
  • Add support non english works in docstring arguments.
  • Fix bug in the contravariant return type check where a contravariant used in a union was not reported.

Behavior Changes:

  • Changed behavior when converting a class to a callable. If the class has no __init__ or __new__ method in its class hierarchy (other than those provided by object), pyright previously converted the constructor to a signature of (*args: Any, **kwargs: Any). It now converts it to a signature of () (i.e. no params) unless it's a type[T] or a protocol class.
  • Modified the isinstance type narrowing logic to retain a TypeVar when narrowing in the positive case and the value is not a constrained TypeVar.

Enhancements:

  • Added "metacls" as an allowed name for the "cls" parameter in a metaclass __new__ method.
  • Improved pyright's enforcement of keyword arguments passed within a class statement when the class has no custom metaclass or __init_subclass__ in its hierarchy. In this case, the object.__init_subclass__ method applies, and it accepts no additional keyword arguments. Also improved the error reporting for __init_subclass__ in general.
  • Improved handling of + operator when both operands are tuples. It now produces a more accurate type when one (but not both) of the two tuples is of indeterminate length.
  • Updated typeshed stubs to the latest version.
  • Added code to CLI to verify file specs passed on the command line. If they don't exist, emit an error and a non-zero exit code.
  • Improved check for second argument to isinstance and issubclass so non-runtime-checkable protocol classes are rejected.
  • Added special-case handling x in y narrowing logic for the case where x is a dict or Mapping and y is an iterable of TypedDicts.
  • Added check for the use of contravariant TypeVars in an inferred return type.
pyright - Published 1.1.335

Published by github-actions[bot] 12 months ago

Bug Fixes:

  • Fixed a bug that resulted in a false positive when validating type consistency between a metaclass instance and type[T].
  • Fixed bug that led to an inconsistency between the use of type and Type when applying isinstance type narrowing in some cases.
  • Fixed recent regression in the CLI that caused the --files command-line parameters to be overridden by the "include" setting in the config file.
  • Fixed bug that led to a false positive when assigning a lambda with *args to a callable type that doesn't contain *args.
  • Fixed a few places where union order resulted in different type evaluation behaviors.
  • Fixed a bug that led to a false positive error when specializing a type alias consisting of a callable parameterized by a TypeVarTuple.
  • Fixed bug that causes a false positive MRO error when creating a subclass of a generic TypedDict and another TypedDict.
  • Fixed a bug that results in incorrect type evaluation of a call expression when the callee is a function parameterized by a TypeVarTuple that has been specialized with a concatenation form.
  • Fixed several bugs in the signature help provider when handling **kwargs parameters typed with an unpacked TypeDict (PEP 692).
  • Added missing check described in PEP 692 where fields within an unpacked TypedDict used for **kwargs cannot overlap other keyword parameters in the same signature.
  • Fixed a false positive reportIncompatibleMethodOverride error under certain circumstances where an overloaded method overrides another overloaded method.
  • Fixed a bug that resulted in incorrect type evaluation when using a TypeVarTuple within a nested Callable type (i.e. a Callable that takes a Callable as a parameter).
  • Fixed bug that resulted in false positive reportIncompatibleMethodOverload error under certain circumstances.
  • Fixed a bug that causes a false positive reportUnnecessaryContains error when self is used on the LHS of the in operator within an enum class.
  • Fixed bug that led to a false negative when assigning type Class to Self@Class.
  • (Contribution by @JelleZijlstra) Fix missing space after "not" unary operator for expressions printed in output of reveal_type.
  • Fixed bug in completion provider that resulted in an attempt to tokenize and parse a binary (native) library file. This led to a crash in some cases.
  • Fixed a bug that results in a false positive error when a __new__ method returns Self for a generic class and the type variable is invariant.
  • Fixed a bug that led to incorrect type narrowing for the x is None in the negative (else) case when x is a bound TypeVar (or Self).

Enhancements:

  • Improved error message for descriptor accesses where binding or type validation fails for the __get__, __set__ or __delete__ methods.
  • Added missing error check for zero-argument form of super() when used within a static method.
  • Improved error message for member accesses.
  • Improved diagnostic message for method overrides based on keyword/position-only parameter mismatch.
  • Enhanced the handling of zero-argument form of super() to support the case where the containing method's self or cls parameter is annotated using a protocol. This can be used to handle mixin methods that call super().
  • Added support for boolean values in diagnosticSeverityOverrides language server setting.

Other Changes:

  • Updated heuristics for constructor evaluation to accommodate a wider range of types returned by the __new__ method. Previously, if the __new__ return type was anything other than a class instance, the heuristics assumed it wasn't intended and assumed that __new__ returned an instance of its class, as is usually the case.
  • Restored previous behavior (prior to 1.1.334) where an instance of a class that derives from Any will not be considered type compatible with None.
  • Significant rewrite of code that handles member accesses on class objects and class instances. This should improve internal consistency and fix many edge-case bugs. Due to the extent of this change, some regressions may result.
pyright - Published 1.1.334

Published by github-actions[bot] 12 months ago

Bug Fix: Fixed a bug that caused locale override to fail to take effect if passed via the LSP initialize message.

Bug Fix: Fixed issue that led to false positive error when calling a NoReturn function within a case block or within an if/elif chain.

Enhancement (contribution by pakrym-stripe): Support unpacked TypedDict in parameter hover.

Performance: Fixed a performance regression that affected symbol type inference in the presence of circular dependencies.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Improved support for runtime TypeVar, TypeVarTuple and ParamSpec objects, including when they are instantiated from typing_extensions classes.

Enhancement: Improved inference logic for lambdas so it handles a wider variety of cases including lambas with *args parameters and cases where the expected type is a union of multiple subtypes that might be matches.

Enhancement: Improved TypedDict update method error message when no overloads match.

Bug Fix: Fixed a bug that led to a false positive when using an unpacked iterable as an argument in a call expression after a keyword argument.

Enhancement: Added support for python.analysis.include, python.analysis.exclude and python.analysis.ignore settings. These have been implemented in pylance for a while now, but they were never implemented previously in pyright. Also fixed a bug in the original implementation that caused the config file not to override the language server settings for python.analysis.exclude and python.analysis.ignore as it should.

Bug Fix: Fixed bug that led to false negative when evaluating a call to a function with a recursive ParamSpec.

Bug Fix: Fixed a bug in the type guard logic for simple truthy/falsy checks. If the type is an instance of object or a TypeVar with no bound (which is treated like an object), the logic should not assume that it will always evaluate to truthy.

pyright - Published 1.1.333

Published by github-actions[bot] 12 months ago

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.

pyright - Published 1.1.332

Published by github-actions[bot] about 1 year ago

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.

pyright - Published 1.1.331

Published by github-actions[bot] about 1 year ago

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.

pyright - Published 1.1.330

Published by github-actions[bot] about 1 year ago

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.

pyright - Published 1.1.329

Published by github-actions[bot] about 1 year ago

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. 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.

pyright - Published 1.1.328

Published by github-actions[bot] about 1 year ago

Behavior Change: Added code to enforce invariance of class-scoped variables in overrides when the reportIncompatibleVariableOverride rule is enabled.

Bug Fix: Fixed bug that results in import resolution errors when symlinks are used.

Bug Fix: Fixed a bug that caused a typing.deprecated decorator not to be marked as such.

Bug Fix: Fixed a bug that resulted in a false positive error when *args and **kwargs are passed as arguments to a function with a ParamSpec and the types of *args and **kwargs is Any.

Bug Fix: Fixed bug that caused @deprecated message not to be passed through a ParamSpec.

Bug Fix: Fixed a bug that results in incorrect type narrowing for a mapping pattern if the subject type is a superclass of Mapping, such as object.

Bug Fix: Fixed inconsistent behavior of @deprecated between overloaded and non-overloaded functions.

Bug Fix: Improved validation of generator return type. Previously, the check was performed only for yield statements, but it's possible to define a generator function that has no reachable yield statements.

Bug Fix: Fixed bug that led to a false positive error when checking for out-of-bounds tuple accesses if the indexed type is a union that includes both a bounded tuple and an unbounded tuple.

Behavior Change: Updated the synthesized pop method for TypedDict so its signature is consistent with the synthesized get method. This eliminates an Unknown in some cases.

Bug Fix: Fixed bug that led to incorrect generation of Unknown type evaluation when an overloaded function is called in a loop and one of the arguments to the call depends on the return value.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a regression that caused an Unknown to appear in a type evaluation when using nested constructor calls.

pyright - Published 1.1.327

Published by github-actions[bot] about 1 year ago

Bug Fix: Fixed a bug in the isinstance type narrowing logic that evaluated the incorrect type when two protocol classes are involved.

Bug Fix: Fixed a bug that led to a false positive error when enclosing ... in quotes when specifying a ParamSpec default value.

Bug Fix: Fixed bug that resulted in false positive error when using a Union[*Ts] value in a binary expression.

Bug Fix: Fixed a recent regression that caused the pythonPath received from the client to be corrupted resulting in import resolution errors.

Behavior Change: Updated class specialization logic to conform to latest draft of PEP 696 when a class type parameter has a default type and that class is bound to one of its methods.

Enhancement: Improved error message for type argument mismatch when in an invariant context.

Behavior Change: Changed behavior to allow a class variable within a protocol to be marked Final without assigning a value to it in the protocol definition.

Bug Fix: Fixed a bug that results in a spurious error under certain circumstances when evaluating the type of a parameter within a nested function whose type refers to an outer-scope type variable.

Enhancement: Added check for a conditional expression that evaluates to a coroutine, which always evaluates to True. This is likely indicative of a missing await keyword.

Enhancement: Improved the type narrowing logic for the len(x) == L type narrowing pattern for tuples. The new logic supports narrowing of tuples with an indeterminate length (a ... entry).

Behavior Change: Removed check for empty body of @overload function.

Bug Fix: Fixed a false positive error when a TypeVar with a default value (as specified in PEP 696) appears within a method after an outer-scoped TypeVar without a default value.

Bug Fix: Fixed a bug that led to a false positive error when a frozen dataclass has an explicit __eq__ method and is used in way that requires it to be Hashable.

Bug Fix: Improved error messages that include module names. Previously, there were inconsistencies in how module names were reported.

Bug Fix: Fixed false positive error when using a forward-declared reference inside of an inlined TypedDict when from __future__ import annotations is in effect.

Bug Fix: Fixed a bug that led to a false negative when using a non-TypedDict base class within a TypedDict class statement.

pyright - Published 1.1.326

Published by github-actions[bot] about 1 year ago

Bug Fix: Fixed a bug in the recently-introduced deprecateTypingAliases feature that resulted in false positives when Counter, OrderedDict and ChainMap were imported from collections.

Bug Fix: Fixed a bug that led to a false positive when an enum literal annotation is used within the enum class definition and from __future__ import annotations is in use.

Bug Fix: Added code to mark symbols as accessed if they're imported directly into a class scope using a from x import y statement.

Bug Fix: Fixed a bug that resulted in a false positive error when assigning an unpacked TypeVarTuple to an unpacked tuple[Any, ...] in an invariant context.

Bug Fix: Fixed bug that results in a false positive error during protocol matching when a NamedTuple is matched against a protocol using _fields or other attributes defined in the NamedTuple class.

Bug Fix: Fixed bug that led to a false positive error when determining whether the target of an awaited call is a NoReturn.

Behavior Change: Changed the default of useLibraryCodeForTypes from false to true in the LSP settings. (It was changed to true in all other places previously, but this case was missed.)

Bug Fix: Fixed a bug that led to an incorrect type evaluation in certain cases where a type argument for a function call argument type is left unspecified (and is therefore assumed to be Unknown).

Bug Fix: Fixed a bug that led to incorrect type narrowing for isinstance when the pre-narrowed type is a generic callable.

Bug Fix: Improved determinism of bidirectional type inference for dictionary, list, set and tuple expressions when the expected type is a union of types that includes more than one plausible candidate. The types in the union are now sorted so type evaluation doesn't depend on the order in which the union was defined.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed bug that led to a false negative when @typing.deprecated is used on an async function.

Bug Fix: Fixed a bug that led to the incorrect type evaluation of a constructor call when bidirectional type inference is used and the expected type is a union that includes more than one compatible instance type.

Bug Fix: Fixed a deviation from the PEP 702 spec which indicates that when @deprecated is applied to an overloaded function implementation, that deprecation is meant to apply to all overloads.

Enhancement: Improved error message for deprecated methods.

Enhancement: Improved "no matching overloads" error message in cases where an argument is unpacked.

Enhancement: Added support for custom metaclasses that inject instance variables into the classes they construct.

pyright - Published 1.1.325

Published by github-actions[bot] about 1 year ago

Bug Fix: Fixed a bug in the isinstance type guard logic that produced incorrect results when narrowing a generic class instance.

Bug Fix: Fixed a bug in the parser that led to a false positive syntax error when a match statement was followed by a - or ~ token.

Bug Fix: Improved logic that determines whether an object is callable. The __call__ attribute must be a class variable, not an instance variable.

Bug Fix: Improved isinstance and issubclass narrowing in the case where an intersection type is created and one of the two subclasses has a custom metaclass.

Behavior Change: Changed type evaluation behavior for a class variable that uses Self in its type definition. When accessed via a subclass (either through cls or self), the type is now assumed to be changed to Self of the child class. This makes pyright's behavior closer to mypy's in this case.

Bug Fix: Fixed regression that resulted in incorrect type evaluation and a spurious reportUnknownArgumentType error when calling the same constructor multiple times in a single call expression.

Bug Fix: Fixed a bug that caused a "py.typed" marker file to be ignored in a namespace package if the marker file is at the same directory level as the submodule being imported leading to a spurious reportMissingTypeStubs error.

Bug Fix: Fixed a bug that led to a false positive during overload matching when the arg type includes a union where one of the subtypes is a constrained TypeVar.

Enhancement: Added a new configuration option deprecateTypingAliases that enables deprecation detection and reporting for symbols imported from the typing module that are deprecated according to PEP 585 and 604. The option is currently disabled by default (even in strict mode) but can be enabled manually.

Behavior Change: Changed logic to exempt abstract overloaded methods within an ABC so an implementation is not required.

Bug Fix: Fixed check for illegal use of zero-argument super within an inner function located within a method.

Bug Fix: Fixed a bug that led to a false negative when a type annotation contains a stringified type on the LHS of an index expression.

Enhancement: Added support for @type_check_only decorator.

Enhancement: Improved error message for type incompatibility when type parameter is covariant or contravariant.

Enhancement: Updated typeshed stubs to the latest.

Bug Fix: Fixed a bug that led to incorrect type evaluation and false positive errors when a function with a ParamSpec was passed to another function with a ParamSpec.

Behavior Change: Changed interpretation of ... forms of tuples to improve consistency and match mypy's behavior. The type tuple[int, ...] is now interpreted as the union of all tuples of length zero or more that contain only int. Because this is a union, assigning a value of this type to a tuple type with a known (specified) length is now considered a type violation.

Bug Fix: Fixed several bugs in the logic for "strict type guard" positive and negative type narrowing.

Bug Fix: Fixed long-standing bug that caused various problems (including poor performance, incorrect type evaluations, and false negatives and false positives) when calling a constructor for a generic class within the class implementation.

Bug Fix: Fixed a bug that led to a false positive reportUnusedVariable error when a dynamic expression was used in a namedtuple call argument.

Bug Fix: Fixed a bug that led to a false positive reportIncompatibleMethodOverride error when a function-scoped type variable was used in a contravariant position.

Bug Fix: Fixed bug that led to the incorrect type evaluation when calling a generic function and a value of type P.args or P.kwargs is assigned to a type variable.

Bug Fix: Fixed a bug that led to a false negative error for an expression used within an f-string within a loop.

pyright - Published 1.1.324

Published by github-actions[bot] about 1 year ago

Bug Fix: Fixed a bug that led to a false positive error under certain circumstances when a callable using Concatenate is assigned to another callable using Concatenate.

Bug Fix: Fixed bug that can result in a false positive error when a wildcard import targets a module that doesn't contain a __all__ definition but includes dundered names in its module namespace.

Bug Fix: Fixed a false positive error when invoking a call of a variable that is annotated using a PEP 695 type alias.

Bug Fix: Fixed a bug that caused an incorrect application of a ParamSpec in certain cases where the signature bound to the ParamSpec was generic.

Enhancement: Improved validation of NamedTuple and namedtuple factory calls.

Enhancement: Improved detection of redundant pattern capture targets in case statements.

Bug Fix: Changed the type evaluation logic for the enum value member so a custom value type can be specified in the Enum subclass.

Bug Fix: Fixed a bug that led to a false positive in the reportIncompatibleMethodOverride check in certain circumstances where the method in both the base class and child class are overloaded.

Bug Fix: Fixed bug that resulted in a false positive error when an async function with no return type annotation was called recursively.

Bug Fix: Fixed a bug that led to a false positive in the reportIncompatibleMethodOverride check when overriding a method with a ParamSpec.

Bug Fix: Fixed a recent regression that resulted in a false positive during protocol matching if the protocol defines an __eq__ method but doesn't include a __hash__ definition.

Bug Fix: Fixed bug that sometimes led to false positives or false negative in call expressions that involve keyword arguments followed by an unpacked.

Bug Fix: Fixed a bug that resulted in the incorrect textual form (used in error messages) for a generic class with a ParamSpec that is parameterized with ....

Bug Fix: Fixed regression that caused a spurious error with the reportIncompatibleMethodOverride check when a method with a ParamSpec was overridden by a method with *args: Any, **kwargs: Any.

Bug Fix: Fixed a bug that led to incorrect type narrowing on assignment in certain cases.

Enhancement: Added check for classes that have mutually-incompatible base classes due to generic type argument mismatches.

Bug Fix: Fixed bug that led to a false positive reportIncompatibleVariableOverride error when overriding a synthesized __hash__ symbol.

Bug Fix: Added heuristic to constraint solver logic to better handle the case where a parameter is annotated with a union of multiple "bare" TypeVars (like S | T). In this case, it's not clear whether the corresponding argument type should constrain S or T or both. We now defer the constraint during the first pass of arg/param type validation so additional references to S or T can help establish the appropriate constraint.

Bug Fix: Fixed a bug that led to incorrect type evaluation of Union[*Ts] (where Ts is a TypeVarTuple) in certain situations

Bug Fix: Fixed bug that resulted in incorrect type evaluation when passing a generic class as a Callable parameter more than once in the same call.

Enhancement: Added logic to mirror the (rather surprising) runtime behavior when an attribute is accessed from a class object and the metaclass defines an attribute of the same name that happens to be a descriptor object. The runtime favors the metaclass attribute in this case.

Enhancement: Extended inlined TypedDict prototype to support TypedDict as well as dict so we can compare the two proposals.

Bug Fix: Changed logic for handling the __get__ method of a descriptor so pyright more accurately models the runtime behavior when the descriptor is accessed through an object (as opposed to a class). Previously, pyright was modeling this as an Any value to avoid problems with type stubs that are not accurately modeling the runtime behavior, but this caused other unintended side effects.

Bug Fix (from Pylance): Fixed bug that led to internally-corrupted type state if the language server canceled a type evaluation request at just the wrong time.

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 case statement using a class pattern that guarantees that the constraint is met on that code path.

pyright - Published 1.1.323

Published by github-actions[bot] about 1 year ago

Bug Fix: Fixed a condition in the code flow engine that corrupted internal state and led to a crash.

Bug Fix: Fixed bug that resulted in incorrect type evaluation for an async function that has no type annotations. It was using call-site return type inference but failing to wrap the result in a Coroutine.

Enhancement (from Pylance): Added support for ".jar" files for import targets.

Bug Fix: Fixed bug that led to false negative when assignment expression (walrus operator) is used in a yield or yield from statement without a parenthesis.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation (and a false positive error) when a binary operator overload method was annotated to return NoReturn.

Enhancement: Updated typeshed to the latest. This update includes some changes to the two-parameter form of the get method for dict and TypedDict that may result in visible type evaluation changes in some code bases.

Enhancement: Added a check for hashability for objects used as dict keys. Contribution from @TheTripleV.

Bug Fix: Fixed a bug that resulted in a false positive reportUnnecessaryComparison error when the subject of a match statement was mutated in a loop.

Enhancement: Added special-case handling of enum fields that are callables, which are apparently not treated as enumerated types.

Enhancement: Added check to enforce a generator's "send type" in a yield from statement.

Enhancement: Added special-case logic for fields with the name __hash__ within a dataclass.

Enhancement: Added support for ... in the last type argument of Concatenate. After much discussion (see https://github.com/python/cpython/pull/30969), it has been decided to support this even though a strict reading of PEP 612 seems to exclude it.

Bug Fix: Fixed a bug that led to a false negative when assigning a dictionary literal expression to a TypeVar bound to a TypedDict.

Bug Fix: Fixed a bug that led to a false negative when a TypeVar was used inappropriately in certain cases.

Bug Fix: Fixed bug in protocol matching that led to an incorrect protocol match with a NamedTuple. Fields in a NamedTuple are implicitly read-only, so a writable protocol should not match.

Enhancement: Added type compatibility enforcement for symbols imported via a wildcard import.

Enhancement: Added support for indexing into tuples of indeterminate length as long as the index is positive and falls within a determinate portion.

Bug Fix: Fixed type narrowing bug that affected the A is B type narrowing pattern when A has the type type.

Bug Fix: Fixed false positive where an inner function within a method uses a TypeVar to annotate its parameter. The variance of the TypeVar shouldn't be checked in this case, whereas it should be for the method.

Bug Fix: Fixed a bug that led to a false positive when accessing a cached_property defined on an enum.

Bug Fix: Fixed a bug in import resolver that caused a site-packages module to be preferred over a local module if the site-packages package is "py.typed".

Bug Fix: Fixed bug that led to a false positive when a two-argument form of a super call used type as the first argument.