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

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

Bug Fix: Fixed bug that resulted in a false positive "partially unknown" error when using an augmented assignment targeting a subscripted expression within a loop.

Bug Fix: Fixed regression in CLI version that caused the default stubsPath value to stop working. This regression didn't affect the language server code paths.

Bug Fix: Fixed a bug that caused an overload function with a missing return type annotation (and a placeholder body) to have an inferred return type of None when it should be Unknown.

Enhancement: Added support for negative (fall-through) type narrowing for mapping patterns used in a case statement when the subject type includes a TypedDict with a discriminated field type (i.e. a field whose value is limited to a particular literal value).

Bug Fix: Fixed bug in constraint solver that results in incorrect code being emitted when overriding a method that includes multiple keyword-only parameters.

Bug Fix: Fixed bug that led to inconsistent behaviors when attempting to assign callable with a tuple parameter where the tuple was of indeterminate length. Previously, this generated an error if the source type parameter was a tuple with zero elements.

Enhancement: Added support for type guards of the form x[I] is B and x[I] is not B where x is a tuple and B is a boolean literal True or False or an enum literal.

Enhancement: Implemented PEP 698 (@override) support for methods decorated with @property decorator.

Bug Fix: Fixed a bug that resulted in a false negative when a self or cls parameter has an incorrect type annotation (not a subtype of the containing class) in an overloaded method.

Bug Fix: Fixed a bug that led to a false positive error when evaluating a call expression that accepts multiple generic callables, at least one of which is parameterized by a ParamSpec, where the generic types of the callables interact when being solved.

Performance: Fixed an issue that resulted in an unnecessary use of memory when transforming certain types that include TypeVars.

Bug Fix: Fixed a bug that led to a false positive when a generic function was passed as an argument to another generic function multiple times. In such a case, the second (and subsequent) instances of the function must be given unique type parameters so they are distinguished from other instances of the same function.

Bug Fix: Changed the evaluated type of an exception group from ExceptionGroup to BaseExceptionGroup.

Bug Fix: Improved type inference for unpacking of tuples that include unpacked tuples whose lengths are unknown.

Bug Fix: Fixed a bug that led to a false positive error when calling a constructor using bidirectional type inference on a generic class that defines a __new__ method but no __init__ method.

Bug Fix: Fixed bug that resulted in a false negative when Never is used as a type argument for an invariant type parameter.

Bug Fix: Fixed a bug that led to a false positive error when applying bidirectional type inference to a call expression that invokes a generic function where the return type includes a generic class with multiple type arguments, some of which are supplied by the expected type and some of which are not.

Bug Fix: Fixed bug that resulted in incorrect type narrowing in the negative (fall-through) case for certain value patterns in a match statement.

Enhancement: Updated typeshed stubs to the latest version.

pyright - Published 1.1.301

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

Bug Fix: Fixed bug that caused diagnostic for implicit override to be reported as part of reportGeneralTypeIssue rather than `reportImplicitOverride.

Bug Fix: Fixed recent regression that caused a crash in the signature help provider.

Bug Fix: Fixed bug that resulted in false positive "incompatible variance" error when covariant and contravariant type variables were used in certain combinations when defining a generic class.

Enhancement: Added support for argument dictionary unpacking when the type of the unpacked object supports the SupportsKeysAndGetItem protocol. Previously, the object needed to be an explicit subclass of Mapping.

Bug Fix: Fixed a bug that led to the incorrect evaluation of a symbol imported through a from a.b import c statement if a.b is a non-py.typed library, useLibraryCodeForTypes is false and c was also the name of a submodule of a.b. In this case, the evaluated type of c should be Unknown, but it was incorrectly evaluated as a module type.

Behavior Change: Reduced verbosity of CLI output for non-error conditions.

Enhancement: Added support for a TypeGuard function where the first argument is a TypeVar. In this case, the resulting (narrowed) type should be a conditional type that references the TypeVar.

Bug Fix: Added support for "naked" ClassVar used to annotate a class variable that is assigned a descriptor object but is later set through an object member access. This previously resulted in a false positive error.

Enhancement: Added support for synthesized __slots__ symbol in dataclasses that are constructed using the slots=True argument.

Bug Fix: Fixed bug that resulted in an false positive error when using a class (and by implication, its constructor) as an input to a generic function (e.g. a decorator) that is parameterized with a ParamSpec.

Bug Fix: Fixed a bug that resulted in a false negative when using a type variable with an incompatible variance to specialize a generic class that uses a TypeVarTuple.

Bug Fix: Fixed bug that resulted in a false positive error when doing protocol matching where the object type (i.e. the self value) is a literal value.

Behavior Change: Tweaked the type constraint solver's "scoring" mechanism to ensure that functions and function overloads are always scored as "more complex" than classes, objects and unions thereof.

Performance: Fixed issue that resulted in unnecessary caching (and therefore unnecessary memory usage) for instances of types that are already considered instances, such as Any and Unknown.

Bug Fix: Fixed a bug that resulted in spurious type evaluation errors when dealing with classes that have synthesized symbols such as dataclasses, namedtuples and TypedDicts.

Bug Fix: Fixed bug that led to a false positive error when a TypeVar was bound to StringLiteral and conditionally narrowed.

pyright - Published 1.1.300

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

Bug Fix: Fixed regression that resulted in a false positive error when using an index expression form with a class whose metaclass supplies a __getitem__ method when the expression is used as a runtime expression, as opposed to a type expression.

Performance: sped up type analyzer by 5-25% by caching types that have been converted to or from an instance. This drops the analysis time of pydantic from 17s to 12s.

Performance: Further improved perf when determining type compatibility of unions with many subtypes. This further reduces the analysis time of pydantic from 12s to 4s.

Enhancement: Added new diagnostic check reportImplicitOverride.

Bug Fix: Fixed bug that resulted in a false positive error relating to variance incompatibility.

Bug Fix: Fixed regression that caused a crash in the presence of the illegal statement import ..

Behavior Change: Changed the logic in the code flow engine so it never attempts to infer a NoReturn return type for a function that lacks a return type annotation. This results in a big speed improvement for some (unannotated) code bases, but it also produces somewhat inconsistent type evaluation results because a function whose type is inferred to be NoReturn by the type checker will not be treated as such if it is called elsewhere in the program.

Bug Fix: Fixed bug that resulted in a crash when user types import without a follow-on module name. This can happen in due corse of typing an import statement.

Bug Fix: Added support for clear and popitem methods on TypedDict instance that is marked @final and has no required entries.

Bug Fix: Improved hover text for methods that are synthesized (e.g. the get method for TypedDict).

Behavior Change: When stub generator encounters an import statement within a try block, it now emits it rather than ignoring it.

Bug Fix: Fixed a bug that can result in infinite recursion (and a subsequent crash) when a class instance is called and the class defines a __getattr__ method.

Enhancement: Added support for @deprecated in an __init__ method when constructing a class.

Bug Fix: Fixed a couple of bugs in the type narrowing logic for class pattern matching. In particular, added better support for NoneType() patterns and cases where the subject type is a union that includes subtypes of the class pattern.

Behavior Change: Improved consistency of type narrowing on assignment when the target is a variable with a declared type and the assigned value is an unknown or partially-unknown type. Previously, if the assigned value was Unknown, the declared type was assumed, but if the assigned value was a union that included Unknown, the narrowed type (including the Unknown) was assumed. We now always include an Unknown in the assigned type so the reportUnknownVariableType diagnostic is reported.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that led to the incorrect type resolution for unsupported function Enum class construction. The resulting type should be Unknown, but it was evaluated as Never.

Enhancement: Extended support for reportUnnecessaryComparison check to handle dataclass types that use a synthesized __eq__ method.

Bug Fix: Fixed regression that resulted in internal corrupt state and odd behaviors like builtin symbols being marked as "not found" in some circumstances.

Bug Fix: Fixed a recent regression that resulted in a false positive error when a multi-part import statement was used and useLibraryCodeForTypes was disabled.

pyright - Published 1.1.299

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

Bug Fix: Fixed bug that caused incorrect evaluation of numeric literals expressed as binary, octal, or hex. These literals were incorrectly represented as "big integers" in some cases, which caused some operations to fail during type checking.

Bug Fix: Fixed display issue with name of module when it is imported implicitly as part of a multi-part import.

Behavior Change: Changed # pyright: basic file-level comment so it overrides "strict" settings specified in the config file or language server settings. This allows an individual file to be "downgraded" from strict to basic.

Bug Fix: Fixed a recent regression that resulted in multi-part imports being evaluated as unknown if a namespace package was used for an intermediate part of the module path and useLibraryCodeForTypes was set to false.

Bug Fix: Fixed regression that led to a false positive error in some cases where when a wildcard pattern is used in a case statement within a loop.

Enhancement: Updated logic for PEP 696 (TypeVarLike "defaults") to change the syntax for ParamSpec default expressions.

Bug Fix: Fixed bug that caused incorrect results with --verifytypes when NewType was used to define a type prior to Python 3.9.

Bug Fix: Fixed a bug that led to a false negative when a non-Generic class has a metaclass that defines a __getitem__ method.

Bug Fix: Fixed a bug that led to incorrect "circular reference" error for a type alias declaration in certain circumstances when that type alias was used in a parameter or return type annotation.

pyright - Published 1.1.298

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

This is a hot-fix release to correct a regression introduced in 1.1.297.

Bug Fix: Fixed a regression that resulted in a false positive in some rare cases when attempting to assign a value to a property with a defined setter.

Enhancement: Updated typeshed to the latest stubs.

pyright - Published 1.1.297

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

Enhancement: Extended logic that searches for site-packages directory within a venv to handle the case where multiple /lib/python3.X/site-packages are present. The new logic prefers the configured Python version rather than picking the first one returned by the file system.

Enhancement: Added support for bidirectional type inference for dictionary expressions with dictionary expansion entries.

Bug Fix: Fixed a bug that led to a false positive error when using the | operator with two dicts whose keys or values are defined as literals.

Bug Fix: Fixed a recent regression that resulted in an incorrect type evaluation when using a __new__ method whose return type annotation is Self.

Enhancement: Implemented missing check for generic type alias specialization when too few type arguments are provided.

Bug Fix: Fixed a bug that resulted in a false negative when defining a generic class that derives from another generic class and the type parameter isn't compatible with the variance of the base class.

Bug Fix: Added logic to detect when a type alias is used in a generic class declaration's base class list and a type parameter used with the type alias is incompatible with the variance required for the type alias.

Bug Fix (contribution by Michael Davis): Declare workspaceFolders support in LSP server capabilities.

Performance: Performance optimization: reduced formatting of error messages in cases where it can be determined that they are not needed (e.g. in speculative evaluation code paths).

Bug Fix: Fixed a bug that caused the variance for type parameters to be incorrectly inferred when an auto-variance class derived from a non-auto-variance class.

Enhancement: Added support for type guard patterns type(x) == T and type(x) != T.

Enhancement: Improved error handling for dictionary expressions that use bidirectional type inference when the key type doesn't match the expected type.

Enhancement: Improved handling of typing.TypeAlias so it can be aliased and re-exported from other files.

Bug Fix: If no files are found and no errors are detected but the --outputjson command-line option is used, a json report should still be issued.

Bug Fix: Made JSON parsing stricter for the pyrightconfig.json file. Previously, a JSON syntax error was not detected or reported.

Enhancement: Removed the need for the binder to understand typing.Required and typing.NotRequired special forms. This allows these forms to be imported, re-exported, and aliased.

Bug Fix: Fixed a bug that resulted in an incorrect reporting of "unreachable code" after a call to a generator function that contains an unreachable yield statement.

Performance: Fixed performance issue that affected long if/elif chains.

Bug Fix: Fixed bug that resulted in incorrect type evaluation of arguments to functools.partial call along with false positive errors. The problem is that the special-case logic for functools.partial was not applying bidirectional type inference when evaluating the arg type.

Behavior Change: Changed import modeling behavior for import statements with multi-part module names. The statement import a.b.c now implies import a; import a.b; import a.b.c. This also affects import cycle detection because these implicit imports are now part of the import graph.

Bug Fix: Fixed a bug that led to a false positive error when using a subclass of type as a base class in a class declaration.

Behavior Change: Changed reportSelfClsParameterName check to accept mcs and mcls for first parameter in an instance method within a metaclass (i.e. a subclass of type).

Bug Fix: Fixed bug that resulted in the incorrect type evaluation for a function or method that returns Union[*Ts] where Ts is a TypeVarTuple bound to *tuple[()].

Bug Fix: Fixed regression in --verifytypes where variables assigned from calls to TypeVar, ParamSpec, TypeVarTuple, NewType, TypedDict, and NamedTuple were marked as ambiguous.

Enhancement: Added an error message for Concatenate if a TypeVarTuple is used in the concatenated list of types.

Bug Fix: Fixed a bug whereby the signature help and hover text for an overloaded method would adopt its class docstring rather than the docstring for its own implementation.

Enhancement: Added check and corresponding error for use of an unpacked tuple in a Concatenate.

Bug Fix: Fixed several bugs relating to types of callables (functions, methods, lambdas). There were bugs in the type printer, call expression evaluator, and param spec specialization logic.

Enhancement: Added experimental support for inlined TypedDict definitions using the dict[{'a': int}] syntax.

pyright - Published 1.1.296

Published by erictraut over 1 year ago

Bug Fix: Fixed a bug that resulted in a false positive when determining the correct variance of a TypeVar used within a class.

Bug Fix: Improved type inference of method calls on super() so Self is generated rather than the concrete class.

Bug Fix: Fixed regression in import resolver that resulted in spurious "stub not found" diagnostics.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation of augmented assignments used in loops in some cases.

Bug Fix: Addressed a performance issue that resulted in long evaluation times when a variable was used in a loop but was not initialized prior to the loop.

Enhancement: Improved support for ternary expressions that use a statically-evaluatable condition expression.

Enhancement: Enhanced the reportUnnecessaryComparison to check for unused patterns in a match statement.

Bug Fix: Fixed bug that caused a false positive when a variable of type type is used as an argument to a class declaration.

Bug Fix: Changed logic to treat self and cls parameters as positional-only for purposes of protocol matching.

Bug Fix: Fixed bug that resulted in a false positive error with assert_type when the evaluated type involved a pseudo-generic class.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Added diagnostic check for when unknown or partially-unknown type is captured by a wildcard pattern in a match statement.

Enhancement (from pylance): Added module name to moduleUnknownMember diagnostic.

Performance: Improved performance by not inferring return type of overloaded implementation when binding an overloaded method to an object.

pyright - Published 1.1.295

Published by erictraut over 1 year ago

Behavior Change: Updated the handling of type narrowing for class pattern matching in cases where a class subclasses from one of the special built-in types listed in PEP 634 as treating a single positional argument as matching the entire subject. The behavior of the CPython implementation deviates from the PEP in this manner, but the implementation takes precedent over the spec in this case.

Bug Fix: Fixed a bug that led to false positive errors when evaluating comparison operator overrides (e.g. __eq__ or __lt__) in cases where the LHS type didn't support the comparison but the RHS type did.

Enhancement: Added logic to exempt a self with annotated type Never from the check that verifies the self type is a subtype of the class.

Bug Fix: Fixed a bug that resulted in an incorrect inferred function return type when one or more of the return statements returned an expression based on an empty container ({} or []).

Bug Fix: Fixed a bug that caused a Final variable to lose its literal value when imported from another file.

Bug Fix: Fixed a bug that resulted in a false positive "overlapping overload" diagnostic in certain cases.

Bug Fix: Fixed a bug that resulted in a false positive diagnostic when using a TypeVarLike with a default value by itself in a function signature.

Bug Fix: Fixed issue that caused the type of None.__class__ to be evaluated incorrectly with new typeshed definition of object.__class__.

Enhancement: Updated typeshed stubs to the latest.

Enhancement (contribution by Declan Brady): Added parameter documentation on hover from function docString.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when a __new__ is called and is bound to a class that is different from the cls argument passed to it.

pyright - Published 1.1.294

Published by erictraut over 1 year ago

Bug Fix: Fixed a bug that led to a false positive error when using a type alias within an __init__ or __hash__ method in a dataclass.

Bug Fix: Fixed a false negative where a variable used within a TypeAlias definition was not flagged as an error.

Bug Fix: Fixed false negative error where an attempt to assign a value of type type[T] to type T was not flagged as an error.

Bug Fix: Fixed a bug that results in a false positive error when using Self in a type annotation for a parameter with a default value.

Behavior Change: Removed typeshed tensorflow stubs because they're too incomplete at this time.

Enhancement (from pylance): Added completions and signature help for unpacked kwargs (PEP 692).

Behavior Change: Change dataClassFieldWithDefault from error to reportGeneralTypeIssue diagnostic so it can be disabled.

Bug Fix: Fixed bug that resulted in a false positive error when calling type(None)().

Enhancement: Improved error handling for constructor call to NoneType.

Bug Fix: Fixed bug that led to incorrect type evaluation when a yield statement was used in conjunction with a declared Iterator return type.

Enhancement: Added error reporting for malformed # pyright comments.

Bug Fix (from pylance): Fixed recent regression in hover text for variable whose type is Unknown.

Bug Fix: Fixed a bug that resulted in a false positive when accessing an instance method from a metaclass (i.e. a class that derives from type) if the self parameter of that instance method is annotated with a type[T] annotation.

pyright - Published 1.1.293

Published by erictraut over 1 year ago

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when accessing instance methods directly from a None instance.

Bug Fix: Fixed a regression that resulted in a crash when resolving overloads with different numbers of parameters and with with arguments that evaluate to Any.

Bug Fix: Fixed a bug that resulted in an inconsistent "import not accessed" diagnostic based on evaluation ordering.

Bug Fix: Tweaked the "type complexity" heuristic to produce more intuitive results in the constraint solver.

Enhancement: Added specialized logic to better handle imports of the form from .x import x where x is later referenced from an inner scope within the module.

Enhancement (from pylance): Modified class and function signatures to make them more textmate compatible.

Enhancement: Improved handling of a class declaration that uses a dynamic unpacked argument type to define its base classes.

Bug Fix: Fixed a bug that resulted in a false positive error and incorrect type evaluation when a lambda is evaluated with an incomplete "expected" type.

Bug Fix: Fixed false negative bug when checking for valid use of identifiers within a type annotation. Variables used within a type annotation should always generate an error, even if the variable is imported from another file.

Bug Fix: Fixed a bug that led to a false positive error when a magic method (such as in a binary operation) was used with bidirectional type inference.

Enhancement: Added error for a dataclass that uses a private attribute name that appears within a synthesized __init__ method.

Enhancement: Implemented support for overloaded functions captured by a ParamSpec.

Enhancement: Updated typeshed stubs to the latest.

Bug Fix: Fixed bug in signature help that resulted in incorrect or misleading signature for a constructor call when the __init__ method accepts no arguments.

pyright - Published 1.1.292

Published by erictraut over 1 year ago

Bug Fix: Fixed a bug that results in a false positive error in certain circumstances when a match statement is used within a loop.

Bug Fix: Fixed a bug that caused a hang when a function that accepted a Callable with a ParamSpec was fed to itself as an argument.

Enhancement: Improved formatting of function signatures in hover text.

Enhancement: Added heuristic to better handle the case where a symbol is imported from two different modules, one in a try block and another in an except block. This pattern can be found in a number of libraries.

Enhancement: Added filtering in hover provider for overloaded constructors. Filtering for other overloaded functions and methods was previously added, but constructors were overlooked.

Bug Fix: Fixed a bug that resulted in an infinite loop in some cases where list lists, sets or dicts were inferred loop construct.

Enhancement: Extended the reportUnnecessaryComparison check to also handle conditions of the form x is None and x is not None.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that resulted in incorrect type narrowing for discriminated TypedDict types when the narrowed expression includes a member access subexpression.

Bug Fix: Fixed bug in command-line version of pyright that led to the inclusion of file names in the output diagnostic report in cases where diagnostics were completely suppressed for that file using the --level option.

Enhancement: Improved type narrowing for truthy tests that involve int, str or bytes values. In the negative case, we can assume that the type is Literal[0], Literal[''] or Literal[b''].

Bug Fix: Fixed bug that resulted in a false positive when trying to assign a value of type NoneType to type[object].

Bug Fix: Fixed a bug that led to a false negative when a backslash character was used within an expression segment of an f-string.

Behavior Change: Modified overload matching algorithm to more closely match that of mypy. In the case where one or more arguments evaluate to Any but those arguments map to parameters whose types are the same, the first overload is selected. Only in cases where an Any argument produces ambiguous results is an Unknown result produced.

Bug Fix: Fixed a bug in the handling of file specs (globs) used for the "include" configuration option. A directory wildcard pattern (**) was not handled correctly.

Behavior Change: Disabled type narrowing for expressions of the form " == X" and != X". These were never documented to work, and they were causing significant performance issues. Also reverted recent attempt to modify the code complexity algorithm, as this change is no longer necessary.

Performance: Addressed performance issue in code that includes loops and many interdependencies between variables with inferred types. The optimization involves the introduction of an incomplete type generation count that is updated when a the type cache is updated in a way that could affect previously-calculated incomplete types.

Bug Fix: Fixed a bug that led to a false positive error about an "unknown type" in certain cases when using an assignment expression (walrus operator) in a loop.

pyright - Published 1.1.291

Published by erictraut over 1 year ago

Bug Fix (from Pylance): Allow non-identifier characters immediately after #region.

Bug Fix: Fixed a bug that led to a crash in certain circumstances where a TypedDict field annotation contained a circular reference to the TypedDict.

Bug Fix: Fixed a bug that led to a crash under certain circumstances when a dictionary expansion subexpression (**val) was used.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation for a symbols within a py.typed module that is contained with a non-py.typed namespace package.

Bug Fix: Fixed inconsistency within isinstance type guard logic when handling the narrowing of a type that contains a union with Any or Unknown.

Bug Fix: Fixed a bug that resulted in a false positive error when generic class with an invariant type parameter is used in specialized form as a type argument for a class with a contravariant type parameter.

Performance: Improved type analysis performance in some cases that involve protocol matching where the protocol incorporates an overloaded method.

Bug Fix (contribution by André Fontenele): Fixed a bug that caused "go to definition" to go to a bogus position within a file in cases where the identifier refers to a module.

Performance: Added optimization to handle unions that contain large numbers of union literals.

pyright - Published 1.1.290

Published by erictraut almost 2 years ago

Bug Fix: Fixed regression that resulted in an incorrect Unknown type when evaluating a list comprehension in a loop.

Bug Fix: Fixed bug that resulted in incorrect contextual evaluation of certain sub-expressions.

Bug Fix: Improved bidirectional type inference logic to handle cases where an expected type includes a TypeVar that is bound to a type that influences the type inference.

Bug Fix: Fixed a recent regression with the truthy/falsy type guard logic when a constrained TypeVar is involved.

Enhancement: Improved error message for implied return type mismatch.

Bug Fix: Fixed bug that resulted in a false positive error when using the | operator for two sets of str values within a join call.

Bug Fix: Moved __init_subclass__ argument validation from the checker to the type evaluator so types of keyword arguments used in the class declaration are evaluated consistently. Prior to this, hovering over a keyword argument sometimes displayed an Unknown type.

Bug Fix: Fixed a bug that resulted in a false negative when binding an object to an overloaded method where all of the overloads have an annotated self type and none of them match the type of the object.

Bug Fix: Fixed a bug that led to infinite recursion in certain circumstances when using a recursive type alias with a type variable.

Bug Fix: Fixed a bug in the type printer that generated incorrect output for bytes literal types that include non-printable characters.

Bug Fix: Fixed a bug that resulted in false positive errors when an f-string uses an escape character sequence within the format string section.

Enhancement: Extended user-defined TypeGuard functions to support objects with __call__ method.

pyright - Published 1.1.289

Published by erictraut almost 2 years ago

Bug Fix: Fixed a bug that resulted in incorrect type evaluation for a callable attribute within a TypedDict or dataclass. If the attribute has no type annotation, it should be treated as a class variable, not an instance variable.

Bug Fix: Fixed a bug that causes incorrect interpretation of a large integer literal value — one that doesn't fit within a 53-bit mantissa.

Bug Fix: Fixed a bug in the truthy/falsy type guard logic when using self (or another bound TypeVar) where the bound class implements a __bool__ method.

Bug Fix (from pylance): Fixed a bug in vscode-languageserver client that caused bogus cancellation assertion.

Bug Fix: Fixed bug in dataclass_transform logic for frozen_default. If the frozen_default is set to True, it wasn't possible to override it with False explicitly.

Bug Fix: Fixed bug that resulted in a false positive error when using the | operator to combine two set objects.

Bug Fix: Fixed a bug that resulted in an infinite loop when tuple addition was used within a loop construct.

Bug Fix: Fixed bug that led to a false positive when using method-scoped type variables in a type annotation for a cls parameter in a classmethod.

Enhancement: Added a new check for a TypeGuard or StrictTypeGuard function that does not have at least one input parameter.

Bug Fix: Fixed a bug that resulted in a false negative when bidirectional type inference was used for a list expression and a list entry with an incompatible type is present.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Added support for x[K] is V and x[K] is not V type narrowing forms.

Enhancement: Added support for the tentatively-accepted PEP 649 (deferred evaluation of annotations) in Python 3.12.

Bug Fix: Fixed a bug that resulted in a crash within the document symbol provider when a "naked" decorator is present.

Enhancement: Added provisional support for draft PEP 702 (marking deprecations using the type system).

pyright - Published 1.1.288

Published by erictraut almost 2 years ago

Bug Fix: Fixed a bug that resulted in a false positive error when accessing __required_keys__ and __optional_keys__ class variables from a TypedDict class.

Enhancement: Added support for type guard forms x is ..., x is not ..., x == ... and x != .... Support for these were recently added to mypy.

Enhancement: Added support for NoneType to be used in an isinstance type guard or match statement.

Bug Fix: Fixed a bug that resulted in a false positive when using heavily-nested call expressions that target overloads. The speculative type cache was not storing information about whether the type evaluation resulted in errors, so incorrect overloads were being chosen in the cached path.

Bug Fix: Fixed a recent regression that led to a false positive in certain cases when a call to a generic function was made within a loop.

Bug Fix: Fixed a bug that resulted in a false positive error in certain cases when using PEP 695 type parameter syntax.

Bug Fix: Fixed a bug that resulted in an incorrect type evaluation when calling a constructor on a class that uses new PEP 696 TypeVar defaults and provides an __init__ but no __new__.

Bug Fix: Fixed a bug that led to a false negative when comparing a function without a *args to a callable type with a *args.

Bug Fix: Fixed a bug in PEP 696 (TypeVar defaults) logic that resulted in a false positive error when a Self type was used within a generic method that also used a TypeVar with a default type.

Bug Fix: Fixed a bug that resulted in incorrect isinstance type narrowing in certain cases when found within a loop construct.

Bug Fix: Fixed a bug that resulted in a false positive error when a generic class used a contravariant type variable and defined a __new__ method that uses cls: type[Self] as a parameter.

pyright - Published 1.1.287

Published by erictraut almost 2 years ago

Bug Fix: Fixed false positive error in parser when an assignment expression (walrus operator) is used in a subscript list without parentheses. This was a syntax error in Python 3.8 and 3.9 but is allowed in 3.10 and newer.

Bug Fix: Fixed regression that caused an incorrect type evaluation in the presence of a doubly-nested loop.

Bug Fix: Fixed bug that sometimes resulted in incorrect type evaluation of tuple expressions used within a loop.

Bug Fix: Fixed a bug in the import cycle detection logic that led to some false negatives.

Enhancement: Addressed type evaluation performance issue by eliminating separate "incomplete type cache" and combining it with the primary type cache.

Enhancement: Improved error reporting for type mismatch involving a return type that is a TypedDict.

Bug Fix: Fixed a bug that resulted in a false positive error when resolving nested overloaded function calls where the correct overload match depends on bidirectional type inference.

pyright - Published 1.1.286

Published by erictraut almost 2 years ago

Bug Fix: Reverted a recent update to the TOML parser that resulted in a regression. This reversion means that some TOML 1.0 features will not be handled correctly.

Bug Fix: Fixed a bug that resulted in incorrect handling of literals in the TypeVar constraint solver. This involved a pretty significant change to the constraint solver logic — one that eliminated some heuristics and special cases.

Bug Fix: Fixed a bug that caused target expressions within a chained assignment to be evaluated in the wrong order (right to left instead of left to right). This resulted in false positives and negatives in some cases where one target referred to another target. This change also makes it illegal to use a Python 2-style type comment on a line containing a chained assignment statement, reflecting the fact that Python 3-style variable type annotations are not legal here either.

Enhancement: Improved handling of TypeVarTuple constraint solving. Previously, if a TypeVarTuple appeared more than once, the corresponding tuple types needed to be identical. The constraint solver now supports the same sort of narrowing/widening within the tuple entries to find the best solution.

Bug Fix: Fixed a bug that led to a false negative during protocol matching if the protocol class refers to itself within an invariant type argument.

Enhancement: Improved handling of generic functions passed as arguments to generic higher-order functions. Pyright is now able to solve the type variables for both the generic callback and the called function.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Improved handling of generic functions passed as arguments to generic higher-order functions that use a ParamSpec. Pyright is now able to solve the type variables for both the generic callback and the called function.

Bug Fix: Fixed a bug in the code flow engine that resulted in incorrect type evaluation in some cases involving double nested loops.

Bug Fix: Improved the method override consistency checks to detect the case where an override uses an *args parameter that is not type compatible with the overridden method's parameter types. Thanks to @mehdigmira for this contribution.

Enhancement: Improved handling of TypeVars that appear only within a Callable within a return type annotation for a function. By a strict reading of PEP 484, these should be bound to the function's scope, but practically, they are bound to the Callable. This allows a function to return a generic callable type. When TypeVars are rescoped in this manner, the TypeVar cannot be referenced within the function body because it is no longer in scope in that context.

Enhancement: Improved error handling for NewType calls

Enhancement: Completed initial implementation of PEP 696. Added support for default TypeVar types that refer to other TypeVars.

pyright - Published 1.1.285

Published by erictraut almost 2 years ago

Enhancement: Implemented a new --level command-line option that allows filtering of 'information' and 'warning' diagnostics.

Enhancement: Updated TOML parser to one that is compliant with the TOML 1.0 spec.

Enhancement: Added logic to detect uses of PEP 604 | syntax that generate exceptions due to runtime limitations. In particular, if one of the operands is a string (i.e. a forward reference) and the other is also a string or a class that is not explicitly specialized, this will result in an exception.

Bug Fix: Fixed recent regression in completion provider that resulted in garbled type information for a symbol that is declared as a function (using a def statement) but transformed into a non-function type using a decorator.

Bug Fix: Fixed a bug that resulted in a false positive error when an index expression with a numeric literal subscript was used in a loop that included a del statement targeting the same index expression.

Behavior Change: Modified the overload matching algorithm to match the behavior of mypy when the overload match is ambiguous because an argument evaluates to Any or Unknown. In this case, the call expression evaluates to Unknown. Previously, pyright used the first of the matching overloads in this case.

Bug Fix: Fixed a bug that led to extremely long type analysis times when determining type compatibility between an recursive type alias and a recursive protocol.

Bug Fix (contribution from @parched): Fixed recent regression that caused reportImportCycles diagnostic reporting to no longer work.

Bug Fix: Fixed a bug that resulted in a false positive error when a property setter or deleter contained function-scoped type variables.

pyright - Published 1.1.284

Published by erictraut almost 2 years ago

Bug Fix: Fixed a bug that resulted in an incorrect type evaluation when using a literal integer index into a tuple that includes an unpacked TypeVarTuple element.

Behavior Change: Removed diagnostic check that detects a non-ellipsis default value in a stub file. This check was based on a now-outdated best practice. We now recommend that stubs include default values for better usability in language servers.

Bug Fix: Fixed recent regression that caused the hover text for a function symbol to be improperly formatted if its type was evaluated to something other than a function.

Enhancement: Exposed new configuration setting analyzeUnannotatedFunctions which corresponds to the --skipunannotated command-line option. Added an information diagnostic for skipped functions.

Bug Fix: Fixed bug that resulted in an incorrect target range when resolving the declaration of an import. There were cases where "Go To Declaration" would take you to a location within the target file that corresponded to the offset of the import statement within the importing file.

Bug Fix: Fixed bugs that resulted in false positive errors when assigning a type to a Callable and when accessing members from a type[T] or a T that is bound to type.

Enhancement: Improved bidirectional type inference for list, set and dictionary expressions when the "expected type" is a union that contains multiple potentially-compatible subtypes.

Bug Fix: Fixed a bug that led to a false positive error when evaluating a recursive type alias definition that uses a generic type that is parameterized using a bound or constrained type variable.

Bug Fix: Added missing diagnostic rule in diagnostics reported as part of the reportImportCycles check. Thanks for @parched for this fix.

Bug Fix: Fixed false positive error in multi-inheritance override check in cases where the override symbol was provided by one of the base classes.

Enhancement: Updated typeshed stubs to the latest version.

Behavior Change: Added check for disallowed expression forms used with TypeAlias and with PEP 695 type statement.

Bug Fix (from pylance): Fixed exclude/include to work with '.' prefixed directories.

Bug Fix: Fixed a bug that led to a false positive when a NoReturn or Never type argument was used for a covariant type parameter.

Bug Fix: Fixed regression that resulted in inconsistent behavior when useLibraryCodeForTypes is false and a symbol is imported from a non-py.typed library.

pyright - Published 1.1.283

Published by erictraut almost 2 years ago

Enhancement: Added support for # pyright: ignore and # type: ignore comments that are not at the start of a comment.

Enhancement: Improved parse recovery for common indent/dedent conditions.

Bug Fix: Fixed recent regression that resulted in a false positive when a type[T] was assigned to a Callable[..., T].

Bug Fix: Fixed a regression related to a recent change in typeshed that caused imports from google.cloud namespace packages to fail.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when assigning an unpacked TypeVarTuple to a regular (non-variadic) TypeVar during constraint solving. This should result in a union of the TypeVarTuple types.

Bug Fix: Fixed a bug that resulted in a false positive diagnostic when importing a symbol from a "py.typed" library that was imported (and re-exported) from a non-"py.typed" library.

Bug Fix: Changed ParamSpec capture logic to track the expression used for a default argument value.

Bug Fix: Fixed a recent regression that led to a false negative when evaluating the type of an unannotated variable in a loop.

Enhancement: Added support for frozen_default for dataclass_transform.

Bug Fix: Fixed recent regression that caused a false positive reportShadowedStdlibModules for relative imports and imports starting with _.

Enhancement: Show doc strings on hover over module names within import statements.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Added small perf optimization for determining type compatibility between two unions, especially in cases where the number of items in the union is large.

Bug Fix: Added logic to limit recursion when handling type compatibility checks between two different recursive type aliases that have the same definition.

Bug Fix: Fixed bug that resulted in a false positive when passing an unpacked dict or unpacked iterable argument to the constructor of a class that has no __init__ and therefore uses object.__init__.

Bug Fix: Fixed bug that led to a false positive error when using an unpacked argument that has a declared type that is a tuple with an unpacked TypeVarTuple.

Bug Fix: Fixed bug that resulted in a false positive reportPrivateImportUsage diagnostic when importing from a py.typed library under certain circumstances.