Skip to content

Published 1.1.336

Compare
Choose a tag to compare
@github-actions github-actions released this 15 Nov 03:14
· 1268 commits to main since this release

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.