pyright

Static Type Checker for Python

OTHER License

Downloads
2.3M
Stars
13.2K
Committers
119

Bot releases are hidden (Show)

pyright - Published 1.1.382

Published by bschnurr 23 days ago

Bug Fixes:

  • Fixed bug that can result in incorrect type evaluation behaviors if a call to type is used within a loop.
  • Fixed bug that results in incorrect type inference for list, set, dict, and tuple expressions that include modules in them.
  • Fixed bug that results in false positive error when using a Final variable in a protocol and a NamedTuple or frozen dataclass as a concrete class.
  • Fixed bug that results in a false negative when assigning a value to a union type that includes the same type variable multiple times in at least one invariant context. This change eliminates the concept of a "locked" constraint tracker, which is no longer needed and was the underlying cause of the bug.
  • Fixed bug that resulted in a "reportIncompatibleMethodOverride" error being reported in the wrong location when a property method has a decorator applied to it.
  • Fixed a bug that results in a false positive when assigning Never to a type variable in a contravariant context.
  • Added check for the illegal use of TypeForm as the second argument to an isinstance or issubclass call.
  • Fixed bug that results in incorrect type narrowing when a value typed as TypeForm is used as the first argument to isinstance.
  • Fixed a bug that can result in a false positive error when a function signature contains a positional-only parameter and a keyword parameter with the same name. This can result from the application of a ParamSpec or through the use of an unpacked TypedDict.
  • Fixed a bug that results in incorrect type evaluation behaviors when a class has a custom metaclass with a __call__ method and a __new__ or __init__ method that provides a different bidirectional type inference context for parameters.

Enhancements:

  • Added special-case handling for the len(t) == L type guard pattern to handle the negative narrowing case where tuple t has a minimum length of L. In this case, the narrowed type can be computed whereas previously it was left unnarrowed.
  • Improved hover text for converters in dataclass-like classes.
  • Updated typeshed stubs to the latest version.
  • Extended reportUnnecessaryComparison to cover more cases involving is and is not operators.
pyright - Published 1.1.381

Published by bschnurr about 1 month ago

Bug Fixes:

  • Fixed bug that results in incorrect type narrowing for sequence patterns in the negative (fall-through) case when the subject is a tuple with an unbounded entry.
  • Fixed recent regression that results in a false positive error when attempting to assign the expression type(Any) to type type[Any].
  • Fixed a bug that results in incorrect evaluation of a variable in a doubly-nested loop that is assigned a value in an assignment expression.
  • Fixed a bug that results in incorrect narrowing of types for TypeIs user-defined type guard in certain cases when variable type is a union.
  • [Contribution by @dcolascione] Fixed bug that results in a condition where imports stop resolving after file edits that change the set of modules that a file imports.
  • Fixed recent regression that results in incorrect type narrowing for isinstance in the negative case when using type as a filter.
  • Fixed bug that results in incorrect reporting of the Python version in a deprecation diagnostic message.
  • Fixed bug that results in incorrect code flow involving a call to a NoReturn callable with a function decorator applied.
  • Fixed bug that results in a spurious "symbol refers to itself" error under very specific conditions.
  • Fixed bug that can theoretically result in spurious errors when evaluating expressions that involve parameter symbols.
  • Fixed bug that results in incorrect type narrowing when TypeIs intersects type[A] with type[B]. Previously, pyright was producing <subclass of type[A] and type[B]> but now produces type[<subclass of A and B>].
  • [From pylance] Fixed recent regression that caused venvPath specified in language server settings to be ignored.
  • Fixed bug that results in a confusing error message extension referencing a missing __set__ method when assigning to a class variable that is not a descriptor object.
  • Fixed a bug that results in a false positive type error and confusing error message when assigning to a class variable that uses Self in its type definition.
  • Fixed a bug that results in spurious "variable not allowed in type expression" errors when a type alias is used in a loop in both a type expression and a value expression.

Behavior Changes:

  • Updated provisional support for TypeForm based on feedback to draft PEP 747.

Enhancements:

  • Expanded reportUnnecessaryIsinstance check to report cases where an isinstance or issubclass call always evaluates to False.
  • Improved error message for type violation in assignment statement where the LHS is an instance variable reference.
  • [From pylance] Update Unicode range tables to match Unicode 16.0, which is used for Python 3.14.
pyright - Published 1.1.380 Latest Release

Published by bschnurr about 1 month ago

Bug Fixes:

  • Fixed a recent regression that results in incorrect type evaluation when using a two-argument form of super() and the second argument is type[Self].
  • Fixed a recent regression that results in a false positive type error when converting certain constructors (such as for the class defaultdict) to a callable type.
  • Fixed recent regression that results in a false positive under certain specific circumstances involving higher-order functions that return generic callable types.
  • Fixed a bug that results in a false positive error during protocol matching because writable class variables defined in a named tuple or a frozen dataclass were considered read-only.
  • Fixed a bug that causes incorrect type narrowing of expressions used within a tuple expression in the subject expression of a match statement.
  • Fixed a bug that results in an incorrect type evaluation of a higher-order function that is passed an overloaded function.
  • Fixed recent regression that results in a false positive error under very specific circumstances involving a function with a TypeVar used in both a contravariant and covariant context and combined by union with other types in the contravariant context.
  • Fixed a bug that leads to a false positive "default value is specified as ..." when using --verifytypes and the function has a decorator applied that uses a ParamSpec.
  • Simplified check for unnecessary isinstance call. Removed a bunch of redundant code and fixed a number of bugs in the process.
  • Fixed a bug that leads to incorrect type narrowing with isinstance or TypeIs when the filter type (the second argument to isinstance) is a subclass of type.
  • Fixed bug that results in incorrect type narrowing for the in (containment) operator when the filter includes class objects (instances of type).
  • Fixed a bug that results in incorrect type narrowing for the x is ... (ellipsis) type guard pattern.
  • Fixed a bug in the stub generator so it properly outputs type aliases that use the PEP 613 TypeAlias qualifier.
  • Fixed bug that causes a crash in the language server under certain circumstances with partially-written code that has syntax errors.
  • Fixed a bug that results in incorrect type narrowing for TypeIs when it is used with a Callable type form.
  • Fixed several inconsistencies and bugs in the isinstance type narrowing code involving callables

Enhancements:

  • Added performance optimization to better handle the case where a tuple expression contains thousands of entries. This is not typically found in hand-written code, but it can appear in computer-generated code.
  • Added support for custom metaclasses that derive from ABCMeta. Classes instantiated from such metaclasses are now treated as abstract.
  • Updated typeshed stubs to the latest version.

Behavior Changes:

  • Changed the behavior of the dictionary expansion operator (**) when used in an argument expression for a call and the operand is a TypedDict. It now takes into account the fact that a (non-closed) TypedDict can contain additional keys with object values. This new behavior is consistent with mypy.
  • Removed support for python-2 raise statements with comma-delimited operands.
  • Changed behavior of raise evaluation logic to allow type of exception to be Never.
  • Changed behavior to allow a value with type _AnnotatedAlias to be used with an implicit __getitem__ call even though this type is not documented or declared in typeshed.
  • Changed stub generator to avoid emitting a from __future__ import statement, which has no meaning in stub files.
  • Removed support for custom callable type guard pattern. Now that typeshed defines this with a TypeIs, we no longer require custom logic here.
pyright - Published 1.1.379

Published by bschnurr about 1 month ago

Bug Fixes:

  • Fixed a bug that results in confusing hover information for an attrs field that uses a converter.
  • Fixed bug that results in incorrect type evaluation when assigning a recursive type alias to a tuple or list.
  • Fixed a bug that can result in difficult-to-reproduce type evaluation errors when modifying code in your editor and using pyright as a language server.
  • Fixed bug that results in the incorrect type when the Callable special form is used in a value expression.

Enhancements:

  • Added check for concatenated bytes and str literals.
  • Added provisional support for draft PEP 747 and the TypeForm special form.
  • Updated some diagnostic strings to refer to "type expression" rather than "type annotation" since they apply to some cases that don't involve annotations.
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 over 1 year 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.

pyright - Published 1.1.282

Published by erictraut almost 2 years ago

Bug Fix: Fixed bug that resulted in false positive error when a recursive type alias involving a union was used in certain circumstances.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when assigning a tuple with an unpacked TypeVarTuple to a tuple with a normal TypeVar.

Bug Fix: Fixed a bug that resulted in a false negative (a missing error) when assigning a union that contains a TypeVar to another union with the same TypeVar.

Bug Fix: Fixed bug that resulted in incorrect type inference for an instance variable that is assigned different types in different places.

Bug Fix: Fixed bug in tokenizer that resulted in false positive error when a floating point literal started with one or more leading zeros.

Bug Fix: Added logic to deal with conflicting namespace packages when one has no __init__.py(i) file and the other does.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that results in a false positive error when a dataclass field in a child class overrides a non-init dataclass field in a parent class.

Enhancement: Added code to report an error if a from __future__ import x statement is not found at the beginning of a file. This results in a syntax error.

Behavior Change: Changed reportUnnecessaryTypeIgnoreComment to to ignore # type: ignore comments if enableTypeIgnoreComments is set to false.

Bug Fix: Fixed a bug that led to an incorrect type evaluation when an empty list or dict literal is included in a list expression with an "expected type" (i.e. bidirectional type inference is being attempted).

Bug Fix (from Pylance): Fixed recent regression that caused false positive errors to appear when using a multi-root workspace.

pyright - Published 1.1.281

Published by erictraut almost 2 years ago

Enhancement: Improved parse recovery for ternary expressions that are missing an else or a post-else expression.

Enhancement: Changed the implicit declared type of a module-scoped doc to be str instead of str | None when a docstring is present at the top of the module.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when dealing with a union of an unpacked TypeVarTuple.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when dealing with a union of an unpacked TypeVarTuple.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when applying a solved unpacked TypeVarTuple in a Union.

Bug Fix: Fixed a bug that resulted in a false positive during protocol matching for a protocol that includes a property with a getter whose self parameter is annotated with a TypeVar.

Bug Fix: Fixed a bug that resulted in sporadic type evaluation errors when a quoted (forward-declared) type was used in a statement with an explicit PEP-613 TypeAlias annotation.

Bug Fix: Fixed bug that resulted in false positive errors when doing protocol matching for a recursive protocol definition. I needed to increase an internal recursion limit to support this.

Enhancement: Updated typeshed stubs to the latest.

Bug Fix: Fixed regression that resulted in errant reportMissingImports diagnostics within stub files.

Enhancement: Improved parse recovery when a suite contains an unexpected indent followed by a dedent that restores the indentation to that of the suite's body.

Bug Fix: Fixed a bug in the evaluation of the "with" statement that resulted in a false positive error when a class implements a context manager via its metaclass.

Bug Fix: Fixed a bug that led to a false positive error when validating the variance of type parameters for a protocol class when a covariant type parameter is used in a return type in the form type[T_co].

Bug Fix: Fixed a bug that resulted in a false positive error when using a cast to a TypeVar.

Bug Fix: Fixed a bug in the type evaluator that could lead to unsolved TypeVars if used in a Callable parameter.

Bug Fix: Fixed recent regression that led to false positive reportUnnecessaryCast diagnostics.