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

Published by erictraut almost 5 years ago

This version of pyright features a rewrite of the type checking engine. I've decided to bump the minor version to 1.1 accordingly. I've done significant testing of the new version, but it's possible (likely) that there will be some regressions or behavioral changes. Please report any problems you encounter, and I'll try to fix them quickly.

The old type checking engine was a multi-pass analyzer. In each pass, it attempted to resolve the types for each symbol at each point in the program. To handle cyclical dependencies between types, it analyzed each file multiple times — often two or three — until all of the types converged to stable values.

The new type checking engine uses a technique called "lazy evaluation". Instead of analyzing each file top to bottom, it visits nodes of the program in whatever order is necessary to resolve each type. It does this across files as necessary. This technique is significantly faster. For most code, you will see an immediate 2x speedup. For pyright's own unit tests, I saw a speedup of about 8x.

Another big change in this version is that VS Code version of pyright defaults to analyzing and reporting errors only for files that are opened in the editor. This matches the behavior of TypeScript and other language services in the VS Code world. If you liked the old behavior of pyright where it reported errors for all source files in your program regardless of whether they were open, you can change this in the VS Code settings (turn off the "pyright.openFilesOnly" setting).

Other changes in this release:

Bug Fix: Fixed bug in TypeVar matching for generics when multiple constrained types were present.

Bug Fix: Fixed bug that caused incorrect errors when import statements were used within an if statement that checks TYPE_CHECKING.

Bug Fix: Fixed a few bugs in type stub generation.

pyright - Published 1.0.84

Published by erictraut almost 5 years ago

This version contains a major change in the way pyright infers the type of local and member variables that have no explicit type annotation.

Bug Fix: Fixed issue in definition provider that caused it to return duplicate definitions for some symbols.

Bug Fix: Fixed a bug in constructor specialization code. The __init__ specialization was being overwritten by the __new__ specialization, often discarding important type arguments in the process.

Bug Fix: Fixed regression in hover provider where it didn't return any hover information for unresolved import symbols.

Bug Fix: Fixed bug where argument value expressions were not evaluated if they didn't match any parameters.

Bug Fix: Fixed bug relating to scoping of variables introduced within list comprehensions.

Bug Fix: Fixed bug in TypeVar matching logic.

pyright - Published 1.0.83

Published by erictraut almost 5 years ago

Enhancement: A rewritten implementation of the code flow and type constraint engine provides better handling of complex code flow like nested loops, try/except/finally statements, etc.

Enhancement: In VS Code extension, changed the logic for how to handle opened files that don't fall within any workspace. Previously, all such files were analyzed in a default workspace using default settings. The new logic uses the current workspace if there is only one. The "default" workspace fallback is still used for multi-root workspaces.

Bug Fix: Fixed bugs in logic that determines when to allow importing a non-stub from a stub file. It's not allowed for third-party files.

Bug Fix: Changed import logic to search for imported symbols in the target module before looking for submodules of the same name.

Bug Fix: Unreachable code is displayed even for files where errors or warnings are suppressed.

Bug Fix: Fixed TypeVar matching logic to avoid adding widened types if the TypeVar was already matched against subclasses of the type that is being added.

Bug Fix: Union types that include Literal[True] and Literal[False] are now collapsed into a 'bool' type.

pyright - Published 1.0.82

Published by erictraut almost 5 years ago

Bug Fix: Fixed type completions for TypedDict classes when TypedDict is imported from typings (versus typing_extensions).

Bug Fix: Fixed bug that affected proper type evaluation for CTypes like c_uint64.

Bug Fix: Changed server to create service on demand, when a file is opened that doesn't match any existing workspace.

Bug Fix: Fixed bug that caused list[x] and List[x] not to be combined into the same union type.

Bug Fix: Added support for proper type inference for assignments that target lists (e.g. [a, b] = [1, 2]).

Enhancement: Added missing methods and attribute to memoryview class in builtins.pyi.

pyright - Published 1.0.81

Published by erictraut almost 5 years ago

Enhancement: Command-line version now exits with a new exit code (3) if the pyrightconfig.json is malformed or cannot be read. Previously, it proceeded to perform the analysis with default settings.

Enhancement: Added support for interleaved for and if clauses within a list comprehension statement. Previously, the analyzer assumed that there would be only one if clause and it would be after all for clauses.

Enhancement: the built-in function issubclass is now supported by the analyzer in the same way as isinstance. It can be used as a type constraint in conditional code flow statements (if, while, etc.), and the reportUnnecessaryIsInstance setting applies to it.

Enhancement: Added support for the @abc.abstractproperty function decorator.

Bug Fix: Fixed a reported bug relating to the handling of the @overload function decorator. This was due to a recent regression.

pyright - Published 1.0.80

Published by erictraut almost 5 years ago

Enhancement: Added code to interpret the python.path VS Code setting in the same manner as the Python VS Code extension. In particular, it now handles the special-case value of "python" to mean "use the default python interpreter" rather than treating it as a relative path.

Enhancement: Added special-case handling of __import__ built-in call so it always returns Any type.

Bug Fix: Fixed bug in code that determines whether code is reachable.

Bug Fix: Fixed static expression evaluation for expressions that involve python platform when no platform is specified.

Bug Fix: Fixed bug in alias resolution logic that caused the definition provider not to take the user to the right location in cases where there were multiple alias hops.

Bug Fix: Changed implicit module symbol __path__ to be properly typed as Iterable[str] rather than str.

pyright - Published 1.0.79

Published by erictraut about 5 years ago

Bug Fix: Fixed regression introduced in 1.0.77 that caused imports of third-party libraries to generate "not a known member of module" error messages.

This version includes a big change in the way pyright tracks variable declarations. This change should not be visible to users. It was done in preparation for an upcoming change in the analysis engine.

pyright - Published 1.0.77

Published by erictraut about 5 years ago

New Feature: Signature help provider now extracts parameter-specific comments and presents them in the help text when typing function arguments.

Enhancement: Added knowledge of __doc__ symbol to all modules.

Bug Fix: Fixed crash that resulted when launching the production VS Code extension in debug mode.

Bug Fix: Fixed recent regression that broke type completions within import statements.

Bug Fix: Fixed issue that caused analysis to fail after repeated edits while in "watch" mode.

This version includes a big change in the way pyright processes import statements. This change should not be visible to users. It was done in preparation for an upcoming change in the type analysis engine.

pyright - Published 1.0.76

Published by erictraut about 5 years ago

Bug Fix: Fixed Windows-specific path processing bug.

Bug Fix: Fixed bug that caused "import cycle" errors to persist even after they were corrected.

pyright - Published 1.0.75

Published by erictraut about 5 years ago

Enhancement: Added support for bidirectional type inference for assignments where the LHS is an indexed expression.

Bug Fix: Switched to a new file system watching mechanism so "--watch" works correctly on Linux.

Bug Fix: Fixed recent regression that caused errors to be reported incorrectly after editing a dependent source file.

pyright - Published 1.0.74

Published by erictraut about 5 years ago

New Feature: Added support for Python 3.8 assignment expressions (aka walrus operator).

Enhancement: Bumped latest stable build of python from 3.7 to 3.8, so the latter is now the default setting for pyright.

Enhancement: Added verbose logging for file system watchers.

Enhancement: Improved robustness of code that invokes the local python interpreter to query for paths. Thanks to Rami Chowdhury for the contribution.

pyright - Published 1.0.73

Published by erictraut about 5 years ago

Enhancement: Exposed WindowError from builtins.pyi file.

Enhancement: Added overload definitions for built-in "open" function so it distinguishes between Io[str] and Io[bytes] if the provided mode argument is a string literal.

Bug Fix: Added support for metaclasses when using magic function lookups. This allows classes, for example, to be used in binary operation expressions.

Bug Fix: Fixed recent regression in "Organize Imports" feature that caused incorrect ordering of imports.

Bug Fix: Fixed issue that caused sporadic type checker errors to be reported when editing or opening certain files within a workspace.

pyright - Published 1.0.72

Published by erictraut about 5 years ago

New Feature: Added support for Python 3.8 "position-only parameters".

Bug Fix: Enum classes are now properly treated as iterable types.

Bug Fix: Fixed several bugs in typestub generation feature, some of which resulted in crashes or out-of-memory errors.

pyright - Published 1.0.71

Published by erictraut about 5 years ago

Enhancement: Changed TypeVar matching to perform type expansion. Removed hack init overload for dict class that was required because we weren't performing type expansion.

Enhancement: Used aggressive bundling and minification to reduce the VS Code download size by over 50%. Shaved 200ms (80%) off its startup time.

Bug Fix: Fixed a case where a Union type alias (e.g. A = Union[T, B[T]]) was not being handled properly.

Bug Fix: Fixed issue where non-type-stub files were imported and analyzed if they were within a directory with an init.pyi file.

Bug Fix: Added code to suppress all analysis and errors of third-party code files.

Bug Fix: Fixed issue where certain types that were already specialized were re-specialized, overwriting the previous type arguments.

pyright - Published 1.0.70

Published by erictraut about 5 years ago

New Feature: Added config switch for reportUnknownLambdaType.

Enhancement: Implemented parameter type inference for lambdas (uses bidirectional type inference where possible).

Enhancement: Extended bidirectional type inference for types that are nested within dictionaries and tuples.

Enhancement: Implemented two-pass argument for parameters that require type variable matching. This allows for better type checking of arguments and provides better compliance with PEP 484 standard.

Enhancement: Improved type completion within lambda expressions.

Bug Fix: Fixed bug that caused type checker to mistakenly analyze third-party source files that are imported by third-party stub files. The analyzer now stops when it encounters a third-party source file, even if it's included by a stub file.

Bug Fix: Fixed bug that caused some unioned types to be dropped because the deduping logic was mistakenly detecting duplicates.

Bug Fix: Fixed handling of augmented expressions that are defined by the special "i" forms of operator magic methods.

Bug Fix: Fixed handling of tuple expressions that contain unpack operations.

pyright - Published 1.0.69

Published by erictraut about 5 years ago

Bug Fix: Fixed regression introduced in previous release relating to yield statements with no expression.

pyright - Published 1.0.68

Published by erictraut about 5 years ago

New Feature: Added support for Python 3.8 ability to use unpack operators within return or yield statements.

New Feature: Added support for Python 3.8 f-string expressions that end in "=".

Bug Fix: Reduced size of pyright extension by 70%+ by deleting large "LSIF" files that have started to be included in some of the dependent modules.

Bug Fix: Fixed analysis of the second (optional) parameter of assert statements.

Bug Fix: Fixed issue that caused Callable type not to be assignable to generic Type[_T] parameter.

Bug Fix: Fixed bug where unpack operation was not allowed in right-hand side of simple assignments.

pyright - Published 1.0.67

Published by erictraut about 5 years ago

New Feature: Added support for "# type: import" with a config switch to disable it ("enableTypeIgnoreComments").

Enhancement: Added support for the implicit "class" symbol that is added to all methods.

Bug Fix: Fixed bug in type checker's handling of assignments to indexed expressions. It was not properly validating that the assigned type was appropriate.

pyright - Published 1.0.66

Published by erictraut about 5 years ago

Bug Fix: Fixed path parsing bugs that affect Windows platform.

Bug Fix: Fixed bug in handling of enums when using index operator.

Bug Fix: Fixed recent regression (interaction between "expected type" logic for list/set/dict literals and type var matching) that caused the type checker to miss some errors.

Bug Fix: Added support for comparison fallbacks (e.g. if < isn't supported, try its complement >).

Bug Fix: Improved PEP 484 compliance with respect to handling of int, float and complex types.

Enhancement: Improved type completion in cases where an index (subscript) construct is used to the left of a member access construct.

pyright - Published 1.0.65

Published by erictraut about 5 years ago

New Feature: Added support for PEP 589 (TypedDict).

Enhancement: Updated all typestub files to the latest from the typeshed repo.

Bug Fix: Fixed issue that caused public member variables with annotated Literal types to not accept a literal assigned value.

Bug FIx: Fixed several bugs in type checker's logic that caused some type violations not to be reported.

Bug Fix: Changed Tuple (with no type arguments) to default to Tuple[...] rather than Tuple[].

Bug Fix: Fixed issue with Literal type arguments. String literals were being parsed as forward-declared types, and some strings generated tokenizer and parser errors.

Bug Fix: Fixed type checker bug where functions and classes were flagged as not being assignable to 'object'.