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

Published by erictraut almost 5 years ago

Enhancement: The reportUnknownVariableType setting now also checks for unknown or partially-unknown types in return type declaration and return value expressions.

Enhancement: Added new setting reportUnknownArgumentType that emits an error or warning when an argument's expression type is unknown or partially unknown. This setting is enabled in strict mode.

Bug Fix: Changed type checker to enforce invariance of type arguments where appropriate. This includes union types.

Bug Fix: Fixed bug in bidirectional type inference in case where provided object was subclassed from the expected type's class.

Bug Fix: Fixed bug in speculative evaluation mode where cached types from older speculative sessions were still being used in newer speculative sessions, giving the wrong answer.

Bug Fix: Fixed logic for detecting abstract methods that are not overridden. The previous logic didn't work when a mix-in class provided the implementation.

pyright - Published 1.1.17

Published by erictraut almost 5 years ago

Enhancement: Updated to the latest version of typeshed type stubs.

Enhancement: Added support for PEP 562's getattr function.

Bug Fix: Fixed bug in handling of Protocol classes with generic type arguments.

Bug Fix: Fixed signature provider so it works with decorator calls.

Bug Fix: Fixed bug in type checking logic for homogenous tuples of arbitrary length.

pyright - Published 1.1.16

Published by erictraut almost 5 years ago

Bug Fix: Fixed bug that resulted in forward references to type aliases being reported as unbound.

Bug Fix: Fixed recent regression in completion provider that caused a crash.

pyright - Published 1.1.15

Published by erictraut almost 5 years ago

Bug Fix: Fixed bug where function was not identified as a generator if its yield statements were unreachable.

Bug Fix: Fixed bug in handling of generic type parameters within a class declaration.

Bug Fix: Added support for None as a type parameter for Literal.

Enhancement: Added error for classes that attempt to derive from Generic more than once.

Enhancement: Added support for literal string value type completion suggestions for call arguments and assignment expressions.

pyright - Published 1.1.14

Published by erictraut almost 5 years ago

Enhancement: Added synthesized overloaded "get" methods for TypedDict classes to support proper return types for each key value.

Enhancement: Added completion support for string literals used for TypedDict index expressions.

Enhancement: Added reportSelfClsParameterName setting and defaulted it to warning. This controls whether pyright emits an error or warning when a "self" or "cls" parameter is missing or is not named consistently with PEP 8.

Bug FIx: Fixed bug where callable class members were not being bound to instance as part of member access operator. As part of this fix, removed the FunctionTypeFlags.InstanceMethod flag, which is now implicit if SStaticMethod, ClassMethod or ConstructorMethod are not set.

Bug Fix: Fixed bug in f-string parsing that resulted in incorrect error reporting when expressions within f-string contained string literals with curly braces or with nested string literals (including nested f-strings).

pyright - Published 1.1.13

Published by erictraut almost 5 years ago

Enhancement: Added special-cases support in type constraint logic for types Tuple[()] and Literal[False], both of which are always falsy.

Enhancement: Added error condition for wildcard import that's not at the module scope.

Enhancement: Added error condition to detect Protocol class passed as second argument to isinstance or issubclass.

Bug Fix: Fixed bug in decorator processing that caused cached_property to always evaluate the property type as Unknown.

Bug Fix: Improved wildcard import logic. It now attempts to honor all assignment in target module. If all is not defined, all symbols except for those starting with an underscore are imported.

Bug Fix: Added support for AsyncIterable as a declared return type for an async generator.

Bug Fix: "Tuple[()]" (the empty tuple) is now printed correctly (rather than "Tuple") in error messages.

pyright - Published 1.1.12

Published by erictraut almost 5 years ago

Enhancement: Added code to detect the case where a subclass attempts to override a non-method (like a property) with a method. Also handle the case where a subclass overrides an overloaded method in the base class.

Enhancement: Added support for overloaded get method.

Enhancement: Improved markdown formatting for completion provider output.

Enhancement: Added missing support for AsyncIterator return type annotations for async generator functions.

Bug Fix: Eliminated the hard-coded white list of exported symbols from builtins.pyi, which is no longer needed. This caused ModuleNotFoundError (introduced in Python 3.8) not to be exposed.

Bug Fix: Fixed text formatting issue in completion provider — missing colon between function name and type.

Bug Fix: Fixed several bugs in hover and completion providers related to modules and submodules.

Bug Fix: Fixed bug that caused VS Code settings (including python.pythonPath) to be ignored in some situations — most notably when a Python source file is opened outside of the context of a workspace.

pyright - Published 1.1.11

Published by erictraut almost 5 years ago

Enhancement: Changed unknown (or unspecified) type arguments to be treated as "unknown" rather than "any" so they are reported as errors in strict mode. For example, dict is now treated as Dict[Unknown, Unknown]. This change uncovered a number of other latent bugs where TypeVar types were being specialized at inappropriate times.

Enhancement: Added ".venv" and ".git" directories to default exclude paths.

Bug Fix: Disabled file system watchers for source files if onlyOpenFiles is set to true (which is the default). This will avoid a bunch of problems that are caused by the file system watchers including high CPU utilization, memory usage, and files that can't be deleted.

Bug FIx: Fixed bug in reportIncompatibleMethodOverride logic. It wasn't properly generating an error when there was a parameter count mismatch.

Bug Fix: Fixed bug that caused incorrect error to be reported when a (non-literal) str type is used as an index for a TypedDict.

pyright - Published 1.1.10

Published by erictraut almost 5 years ago

New Feature: For functions whose input parameters are missing type annotations, Pyright can now infer the return type based on the argument types passed at the call site.

New Feature: Added new configuration option "reportDuplicateImport" that generates an error or warning when a symbol or module is imported more than once in a source file.

Enhancement: Improved type completion for import statements to filter out directory names that contain characters that are not allowed for module names (periods and hyphens).

Bug Fix: Fixed bug in tokenization of f-strings. It caused expressions within string formatting directives to go unevaluated.

Bug Fix: Fix crash caused by non-breaking space token in a module name.

Bug Fix: Fixed bug in tuple assignment logic. It wasn't properly handling the form Tuple[X, ...], which represents a tuple with arbitrary length.

Bug Fix: Fixed bug related to the type logic for dictionary expansion entries that were typed with "Dict" rather than "dict" class.

Bug Fix: Fixed bug in type completion logic that resulted in auto-imported symbols being added to import statements multiple times if they were already imported.

Bug Fix: Fixed bug in auto-import type completion logic that caused auto-imported symbol to be inserted in the wrong order if it was alphabetically first.

Bug Fix: Fixed incorrect ID in pyrightconfig schema file (a copy-and-paste bug).

pyright - Published 1.1.9

Published by erictraut almost 5 years ago

Enhancement: Added support in completion provider for named parameter suggestions within argument lists for call expressions.

Bug Fix: Fixed bug in type var matching for contravariant type vars.

Bug Fix: Changed *args parameter to be typed as Tuple rather than List, as per the python spec.

Bug Fix: Fixed errant "unbound" error for variable that's declared in an outer execution context and referenced via a closure.

Bug Fix: Changed file system watcher logic to allocate a single chokidar watcher for all include paths rather than one each.

Bug Fix: Added default excludes of **/node_modules and **/__pycache__ because these are almost never intended to be scanned for tracked source files.

Bug Fix: Changed type var matching logic for constrained type vars. The previous logic constrained types to an exact match of the specified constraints, whereas derived types should be permitted. It was based on a misreading of PEP 484.

pyright - Published 1.1.8

Published by erictraut almost 5 years ago

Bug Fix: Fixed bug that caused properties with generic return types to not be specialized correctly.

Bug Fix: Added support for property getters, setters and deleters that have generic types for the "self" parameter.

Bug Fix: Silenced a noisy error message related to file system watcher.

Bug Fix: Added missing translation layer that translates configured platform (e.g. "Windows") into the corresponding sys.platform string (e.g. "win32").

Enhancement: Added support for type constraints of the form "X == None" and "X != None".

Enhancement: Changed the behavior of VS Code extension when no pyrightconfig.json is present. It now defaults to include all source files under the root workspace directory. This was already the behavior for the command-line version of pyright.

pyright - Published 1.1.7

Published by erictraut almost 5 years ago

Enhancement: Added "related information" diagnostic for attempts to override methods in incompatible manner and overrides for @final methods.

Bug FIx: Fixed regression in type evaluator that broke completions in cases where there was a parse error (e.g. when typing a dot as part of a partially-completed member access expression).

Bug FIx: Fixed type inference of "self" and "cls" parameters for methods in a Protocol class so they are not reported as unknown.

Bug FIx: Fixed crash due to hover provider accessing an unreachable node.

pyright - Published 1.1.6

Published by erictraut almost 5 years ago

New Feature: Added hover, definition, reference and rename support for named arguments.

Enhancement: Made some changes that improve responsiveness during large analysis in VS Code.

Enhancement: Augmented some diagnostic messages with "related information" (e.g. a location in another file that helps explain the error or warning).

Enhancement: Improved error reporting for declaration collisions.

Enhancement: Added bidirectional type inference for yield statements.

Bug Fix: Disabled file system watcher polling on MacOS to help eliminate reports of high CPU utilization and heap overflows.

Bug Fix: Fixed bug in type checker where hovering on some expressions before the file was fully checked caused incorrect errors to be generated.

Bug Fix: Fixed type checker's handling of constrained TypeVars.

Bug Fix: Fixed a couple of bugs relating to type checking of generic protocol classes.

Bug Fix: Added missing newline character in --help output.

pyright - Published 1.1.5

Published by erictraut almost 5 years ago

New Feature: Added support for Python 3.8 @final decorator, which can be applied to both classes and methods.

Enhancement: Parser is now pickier about supported syntax for type annotation expressions.

Bug Fix: Fixed handling of 'typeshedPath' setting. The code was assuming that it was an absolute path, but relative paths should also be supported.

Bug Fix: Some Mac users have reported ongoing high CPU utilization. I suspect this is related to the file watching library used in pyright. I've made some adjustments that I hope will avoid this behavior.

pyright - Published 1.1.4

Published by erictraut almost 5 years ago

Enhancement: Exposed the useLibraryForTypes setting in the command-line version of pyright ("--lib" switch).

Enhancement: Updated typeshed type stub files to the latest version from the typeshed repo.

Enhancement: Revamped how properties are handled. Rather than define a custom "PropertyType" that requires its own handling everywhere, a property is now modeled as regular ObjectType whose associated class type has a special ClassTypeFlag. This eliminates a bunch of edge cases that didn't previously work with properties, including support for custom properties.

Bug Fix: Changed code to allow comma delimiters within namedtuple field definition strings.

Bug Fix: Changed import logic to better match behavior of python loader. If there's an empty directory and a python file with the same name, the import resolution logic now selects the file rather than failing resolution.

Bug Fix: Fixed stack overflow due to infinite recursion in lazy binding callback caused by import loops in some packages like numpy.

Bug Fix: Fixed bug where symbols that couldn't be resolved through wildcard imports were resolved as unbound rather than unknown.

Bug Fix: Added code to switch the working directory to the root of the extension before invoking the python interpreter to query sys.path.

Bug Fix: Fixed recent regression that caused symbols imported through "from X import Y" statement not to be flagged as an error if Y was not defined in X's namespace.

Bug Fix: Fixed bug in document symbol provider where it was not providing the correct ranges. This caused the "outline" view in VS Code not to report which outline item contained errors.

Bug Fix: Added support for static evaluation of "typing.TYPE_CHECKING" (in addition to just "TYPE_CHECKING").

pyright - Published 1.1.3

Published by erictraut almost 5 years ago

New Feature: The command-line version now accepts a command-line switch "outputjson". If provided, the output is a JSON structure including all diagnostics (errors and warnings). This format is useful for when pyright is used in a tool chain (e.g. a build system). It eliminates the need for consumers to parse the text output.

Enhancement: Added support for PEP 561 provision for type stubs that are packaged separately from a main package and placed in a peer directory ending in "-stubs".

Enhancement: Improved type completions for method definitions. When defining an override method from a base class, pyright now fills in the type signature for you.

Enhancement: Improved type widening rules for Literal types during TypeVar matching.

Enhancement: Improved printing of literal types. They're now combined (e.g. "Literal[1, 2]" instead of "Union[Literal[1], Literal[2]]").

Bug Fix: When typing floating-point values, type completion suggestions shouldn't be presented after the "."

Bug Fix: Added code to match syntax error detection and scope binding rules defined in PEP 572 for assignment expressions found within list comprehension expressions.

Bug Fix: Fixed issue where the progress spinner wasn't immediately hidden when onlyOpenFiles setting was toggled from false to true.

pyright - Published 1.1.2

Published by erictraut almost 5 years ago

New Feature: Added a new VS Code setting called "useLibraryCodeForTypes". It's disabled by default currently. If enabled, pyright will attempt to extract type information from library code implementations in the absence of type stub files.

New Feature: Added support for hierarchical document symbols, which appear in the "Outline" view within VS Code.

Bug Fix: Fixed regression in "find symbol in workspace" command if onlyOpenFiles is set to true.

Bug Fix: Added code to honor the behavior specified in PEP 484 for imported symbols within type stub files. Only symbols imported using the "as" form of import statements or wildcard imports should be considered exported from the type stub.

pyright - Published 1.1.1

Published by erictraut almost 5 years ago

Enhancement: Implemented an optimization that further sped up analysis by about 10%.

New Feature: Added reportAssertAlwaysTrue configuration switch, which flags situations where an assert statement uses an expression that always evaluates to true.

Bug Fix: Fixed edge cases in abstract class detection and reporting of attempts to instantiate an ABC.

Bug Fix: Fixed a couple of behavioral regressions related to the recently-added onlyOpenFiles setting.

Bug Fix: Fixed a regression where imported symbols from unresolved imports were flagged as "unbound" rather than being treated as unknown.

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.