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

Published by erictraut about 4 years ago

Bug Fix: Fixed the handling of backslashes within an f-string that is also raw.

Enhancement: Added streaming support for "find all references" so updates appear incrementally.

Enhancement: Improved some internal type transforms to preserve type alias information where possible. This helps types be more readable in hover text and error messages.

Bug Fix: Fixed bug that caused identifiers with non-ASCII characters to sometimes be handled incorrectly.

Bug Fix: Fixed bug that resulted in an incorrect "unbound variable" error when the variable was used in an assignment expression within an if/else conditional expression.

Bug Fix: Fixed bug where implementation of an overloaded function was included in the list of overloads leading to incorrect signature suggestions and false positives for various overload diagnostic checks.

Enhancement: Updated typeshed to latest.

Bug Fix: Added missing descriptor for "python.analysis.extraPaths" in Pyright VS Code extension. This caused VS Code to indicate that this setting wasn't known.

Bug Fix: Fixed bugs in import resolver when a project contains multiple namespace packages with the same name.

Bug Fix: Fixed bug that resulted in "unknown" parameter type when assigning a lambda to a variable with a declared Callable type.

Bug Fix: Fixed issue with call signature arguments.

Enhancement: Added support for plain text doc strings.

Bug Fix: Fixed bug that caused a type variable to be "unknown" in some cases where a generic class type was used without providing explicit type arguments.

Bug Fix: Fixed handling of "Annotated" type introduced in PEP 593. Wasn't properly handling string literals in type arguments.

pyright - Published 1.1.78

Published by erictraut about 4 years ago

Bug Fix: Fixed regression were diagnostics reported for constructor argument expressions were being suppressed.

Bug Fix: Fixed bug that was causing "self is unknown type" errors in strict mode for "self" parameters used within a protocol class.

Enhancement: Added support for arbitrary expressions in decorators for Python 3.9 and newer as specified in PEP 614.

Enhancement: Implemented provisional "TypeGuard" functionality that allows for user-defined type guard functions. This must still go through a spec'ing and ratification process before it is finalized. Until then, details could change.

Enhancement: Added diagnostic messages for incorrect use of contravariant type variable as a method return type or a covariant type variable as a method parameter.

Bug Fix: Added missing comparison operator methods (__eq__, __lt__, etc.) for dataclass.

pyright - Published 1.1.77

Published by erictraut about 4 years ago

Bug Fix: Fixed bug where float and complex values were being inferred as Literal types when PEP 586 clearly states that complex and float values are not supported for Literal.

Bug Fix: Fixed spurious "variable is unbound" error when symbol was used in a compound conditional expression where the first part of the expression was statically determined to short-circuit the evaluation (e.g. if False and name:).

Bug Fix: Fixed regression relating to bidirectional type inference used for constructor calls.

Bug Fix: Fixed bug that caused an internal error (stack overflow) when analyzing types of symbols that mutually depend upon each other and are potentially (but turn out not to be) type aliases.

Bug Fix: Improved handling of constrained type variables where one of the constraints is a narrower version of another.

Bug Fix: Eliminated spurious "cannot instantiate abstract class" error when the value being instantiated is typed as Type[X]. Even though X is abstract, this shouldn't generate an error because Type[X] means "any subclass of X".

Bug Fix: Fixed handling of bidirectional type inference when source is an expression involving an "and" or "or" binary operator.

Enhancement: Changed type printing logic to include the name of a module for module types for clarity. Rather than 'Module', it now prints 'Module("")'. This string is used in hover text and diagnostic messages.

Bug Fix: Fixed bug in hover provider where it incorrectly labeled variables as "type alias" if they are instantiated from a type alias.

Bug Fix: Fixed bug that caused type narrowing for assignments not to be applied when the source of the assignment was a call to a constructor.

Enhancement: Improved type narrowing for assignments when destination is declared with one or more "Any" type arguments.

Enhancement: Improved bidirectional type inference for list and dict types when destination type is a union that contains one or more specialized list or dict types.

Enhancement: Improved support for generic recursive type aliases. Improved bidirectional type inference for list and dict types when destination type is a wider protocol type (like Iterable, Mapping, Sequence, etc.).

Bug Fix: Added escapes in docstring markdown converter for "<" and ">" characters so they are not interpreted as an HTML tag by the markdown renderer.

pyright - Published 1.1.76

Published by erictraut about 4 years ago

Bug Fix: Fixed spurious error when "Literal" was used with a dynamic type argument in a place where a type annotation wasn't expected.

Enhancement: Improved type verification report for readability.

Bug Fix: Fixed bug where Enum constructor was not handling some variations of parameter types.

Bug Fix: Fix handling of pythonPath setting when it is unset.

Enhancement: Improved logging for import search paths.

Enhancement: Improved experience for auto-import completions by including "Auto-import" in details.

Enhancement: Added optimizations in type validator to avoid checking built-in classes.

Enhancement: Added checks in type validator for metaclasses.

Bug Fix: Improved handling of bidirectional type inference when RHS of assignment is a constructor.

Bug Fix: Added support for __all__ assignments that include a type annotation. Added support for the __all__ += <module>.__all__ idiom for mutating the __all__ value. This idiom is used by numpy.

Bug Fix: Fixed bug that caused symbols referenced by __all__ not to be marked as accessed in some cases.

Enhancement: Added diagnostic check for static and class methods used for property getters, setters and deleters.

pyright - Published 1.1.75

Published by erictraut about 4 years ago

Bug Fix: Fixed bug that caused some source files that were part of a "py.typed" package to not be identified as such. This meant that the special rules for "py.typed" exports were not being applied in those cases.

Enhancement: Updated typeshed stubs to the latest.

Behavior Change: Added special-case handling of values within enum classes in a py.typed package. They should be treated as constants and not require type annotations.

Behavior Change: Improved detection of implicit type aliases.

Bug Fix: Fixed bug that caused incorrect error in case where bidirectional type inference was used with a list expression and the expected type was an empty protocol.

Bug Fix: Fixed a bug where spurious errors were generated when using an unannotated "self" as an argument to a constructor in a generic class.

Enhancement: Added type narrowing for expressions of the form " in X" and " not in X" where X is a union of TypedDict instances.

Bug Fix: Fixed several bugs related to recursive type aliases. The hover text was sometimes incorrect, type narrowing for "isinstance" was broken in some cases, and the reportUnnecessaryIsInstance rule was reporting incorrect errors.

Bug Fix: Fixed bug in code that prints function types that contain a "named-parameter separator" (""). It was emitting an extra slash ("/").

Enhancement: Added check for position-only argument separator ("/") appearing as the first parameter in a parameter list. This is a syntax error.

Bug Fix: Fixed incorrect handling of global name bindings when a same-named nonlocal name was present.

Enhancement: Expanded support for idioms used in libraries to define __all__. Tuples are now supported, as are calls to expand, append and remove.

Bug Fix: Fixed bug with synthesized __set__ and __del__ property methods. The wrong parameter types were being specified for the 'self' and 'obj' parameters.

Bug Fix: Fixed bug in diagnostics reporting logic that caused stack overflow in some rare cases.

Bug Fix: Fixed bug in callable type narrowing logic where the union of the type includes None.

Bug Fix: Improved handling of bidirectional type inference for constructor calls on generic types. In particular, the new logic better handles the case where the expected type is a union.

Bug Fix: Fixed bug in type inference for generator types. It was not properly adding the three type arguments for Generator in the inferred return type.

Behavior Change: Implemented new rules for reexports within a py.typed module. ".py" files now follow PEP 484 rules with an override based on __all__.

New Feature: Implemented new "verifytypes" command-line option that analyzes a py.typed package and reports missing or partially-unknown types.

Enhancement: Added limiter for list type inference to clip the number of unique subtypes and avoid poor performance in some cases.

pyright - Published 1.1.74

Published by erictraut about 4 years ago

Bug Fix: Fixed bug that caused some type aliases defined in ".py" files within a py.typed package to be treated as unknown.

Bug Fix: Fixed bug relating to member access expressions used in the LHS of an assignment where the inferred type of the member is an object that does not provide a __set__ method. This should generate an error, and it was not.

Bug Fix: Fixed bug in completion provider that sometimes resulted in detailed completion information not to be displayed. The provider was making use of an internal "symbol ID" to resolve symbol information lazily when the item was selected from the completion menu, but the symbol ID was not guaranteed to be the same from one call to the next.

Bug Fix: Fixed a bug where an overloaded function could not be assigned to the type 'object' without generating an error. This should be allowed.

Bug Fix: Fixed bug with the invocation of the __get__ method. It was not being bound to the correct object when called, resulting in incorrect type variable resolution if the "self" parameter was annotated with a TypeVar.

Behavior Change: Eliminated string literal highlighting within document highlight provider. We received significant user feedback that this was not desirable.

Bug Fix: Fixed bug in handling the two-argument form of "super". The type evaluator was not properly honoring the second argument, which specifies the class or object that should be use for binding.

Performance Improvement: Changed the logic that infers the type of a list, set, or dict to look at only the first 64 entries. There were cases where thousands of entries were provided in list and dict statements, and this resulted in very poor performance. In practice, looking at the first 64 entries as part of the inference heuristic is sufficient.

Bug Fix: Fixed bug that caused a enums to be incorrectly reported as "not iterable" in cases where a generic Type[Enum] was used.

Bug Fix: Fixed bug where type aliases that referred to literals would have those literal values stripped if the type alias was declared within a class.

Bug Fix: Made the printing of literal types more consistent within error messages and hover text. If the type is an literal type (as opposed to a literal instance), it is now consistently printed as Type[Literal[...]].

Bug Fix: Fixed bug in the handling of overloaded magic methods associated with arithmetic operators. If no overload was found in the primary method (e.g. __add__), it was not properly falling back on the reverse method (e.g. __radd__).

Bug Fix: Fixed bug that caused the type checker to indicate that None was not compatible with the Hashable protocol.

Enhancement: Improved support for constrained TypeVars. The list of constrained types is now honored when providing completion suggestions and when narrowing types for isinstance/issubclass calls.

Enhancement: Improved type checking for binary operations. Previously, if the right-hand operand was a union and at least one subtype was supported, no error was reported. The new implementation verifies that all subtypes are supported and emits an error if not.

Bug Fix: Fixed bug that reported incorrect error when attempting to index a symbol whose type was annotated with "Type[enum]".

Enhancement: Improved reporting of errors for call expressions, especially in the case where the call type is a union and one or more subtypes are not callable.

Bug Fix: Fixed a bug in the handling of wildcard imports when a dunder all symbol is present in the target and the dunder all array refers to an implicitly-imported submodule.

pyright - Published 1.1.73

Published by erictraut about 4 years ago

Behavior Change: Changed reveal_type to return a string literal that represents the printed version of the type.

Behavior Change: Changed reveal_type to use an information diagnostic severity rather than warning. Added support in CLI for information diagnostic severity. These were previously dropped.

Bug Fix: Tweaked the logic for py.typed type inference. Assignments that are type aliases should never be ignored in a py.typed package if they are defined in a pyi file.

Bug Fix: Fixed bug in the parser relating to assignment expressions. It was not allowing for ternary expressions in the RHS.

Bug Fix: Fixed a bug that caused an incorrect error to be reported when a callable type was assigned to an 'object'. This should be allowed.

Bug Fix: Fixed bug in the completion provider where it was not properly handling object references through "self".

Bug Fix: Fixed bug in the type checker with respect to member accesses where the LHS is a class and the RHS is a property. This should evaluate to a property object.

pyright - Published 1.1.72

Published by erictraut about 4 years ago

Bug Fix: Changed the type of __path__ attribute for a module from Iterable[str] to List[str].

Bug Fix: Fixed a bug that caused a crash in the type checker in some rare cases when a function or class declaration was located within a block of code is unaccessible.

Behavior Change: Changed python.analysis.logLevel to use "Information" rather than "Info" for consistency with Python extension.

Bug Fix: Changed comment-style type annotations for functions to always allow forward declarations.

Behavior Change: Added special-case logic for the tuple constructor. Rather than returning a type of tuple[_T_co], it now returns a type of tuple[_T_co, ...].

Behavior Change: Changed behavior of type evaluator for modules within a "py.typed" package when "typeCheckingMode" is not "off". If it encounters an unannotated symbol, the type evaluator no longer attempts to infer its type. Instead, it returns an unknown type. When "typeCheckingMode" is "off" (the default value for Pylance), inference is still used.

Enhancement: Improved reportMissingTypeArgument diagnostic rule to report cases where some type arguments are provided but some are missing. Previously, it detected only those cases where no type arguments were provided.

Bug Fix: Fixed bug that caused incorrect error to be generated when a yield was used within a lambda.

pyright - Published 1.1.71

Published by erictraut about 4 years ago

Behavior Change: Added code to disable the Pyright extension when the Pylance extension is installed. The two extensions are not intended to work together.

Bug Fix: Fixed bug in handling of specialized "tuple" class as defined in PEP 585.

Behavior Change: Changed the behavior of the command-line version of pyright when file specs are passed on the command line. Previously, file specs couldn't be used in conjunction with a config file. Now a config file is used, but the specified file specs override the "include" section of the config file.

Enhancement: Added validation of arguments passed to __init_subclass__ method described in PEP 487.

Enhancement: Added detection of duplicate base classes in a class declaration.

Bug Fix: Fixed bug that generated incorrect "could not create consistent mro" error if one of the base classes was "Generic". The Python interpreter appears to special-case this class.

New Feature: Added support for new "reportWildcardImportFromLibrary" diagnostic rule that checks for the use of wildcard imports from non-local modules. By default, it is reported as a warning, but in strict mode it is an error.

Enhancement: Added code to synthesize custom overloaded "pop", "setdefault", and "delitem" methods for TypedDict classes.

Enhancement: Added support for the direct instantiation of a metaclass rather than using the normal metaclass hook.

pyright - Published 1.1.70

Published by erictraut about 4 years ago

Enhancement: Added support for PEP 585. Standard collection types defined in builtins can now be used like their typing counterparts. This includes "tuple", which needs special-case handling because its class definition in builtins.pyi indicates that it has a single type parameter, but it actually supports variadic parameters.

Bug Fix: Added code to prevent heap overrun errors during parsing/binding, most notably during indexing operations.

Bug Fix: Fixed bug that caused runtime crash if typeshed stubs couldn't be found or didn't define 'tuple'.

Bug Fix: Improved interaction between recursive type aliases and bidirectional type inference for lists and dicts.

Bug Fix: Improved type narrowing for assignments in cases where the destination of the assignment is declared as a union and the assigned type is a narrower form of one of the union elements. Previously, the narrowing logic didn't choose the narrowest type possible in this case.

Enhancement: Added perf optimization for unions that contain hundreds or thousands of int literal values. This is similar to another recent optimization for str literal unions.

From Pylance: Ensure that auto-import doesn't place import statement below usage.

pyright - Published 1.1.69

Published by erictraut about 4 years ago

Enhancement: Improved type analysis perf by about 5% and reduced memory usage slightly by not formatting and logging diagnostic messages in cases where they are suppressed (e.g. argument type mismatches when doing overload matching).

Bug Fix: Fixed bug that affected dependency tracking of source files on platforms with case-insensitive file systems. In some cases, the case of paths differed, and the logic was treating these as separate files.

Enhancement: Added diagnostics for type variables that are used improperly as defined in PEP 484: 1) conflicting type variables that are used in nested generic class declarations, and 2) type variables that are used within annotations outside of a context in which they have meaning.

New Feature: Added support for "higher-order" type variables. You can now pass a generic function as an argument to another generic function, and the type var solver can solve the type variables for both at the same time.

New Feature: Added support for recursive type aliases.

Behavior Change: Updated the default Python version from 3.8 to 3.9. This is used only if it is not otherwise configured and there is no Python environment from which to determine the version.

Enhancement: Added checks for usage of certain built-in types that are defined as generic in the typeshed stubs but generate runtime exceptions if subscripted on older versions of Python (prior to 3.9). Such types need to be enclosed in quotes when used in annotations.

pyright - Published 1.1.67

Published by erictraut about 4 years ago

Bug Fix: Fixed bug that caused the recently-added "discriminated field type narrowing" to be used in cases where it should not. This resulted in types being narrowed inappropriately when a field was typed as a union of literals.

Behavior Change: Changed command-line version to not print any non-JSON output when "--outputjson" option is used.

Behavior Change: Changed behavior when "useLibraryCodeForTypes" is set to "false". Previously, all ".py" library code was ignored in this case. Now, ".py" types are used for types if the package has an associated "py.typed" file as specified in PEP 561. Packages with no "py.typed" file will still be ignored if "useLibraryCodeForTypes" is "false".

Bug Fix: Fixed a couple of bugs that resulted in the hover text incorrectly identifying a symbol as a "type alias".

Behavior Change: Changed type inference logic to use "List", "Set", and "Dict" rather than "list", "set" and "dict" when inferring the type of a list, set or dict expression. These are aliases for the same underlying class, but the upper-case versions are more consistent with type annotations used within the code.

Bug Fix: Fixed "NoReturn" inference logic for async functions. This logic was previously flagging the code after a call to such a function as unreachable.

Enhancement: Improved parser to detect syntax errors involving unpack operator within a comprehension.

Enhancement: Changed import resolution logic to allow binaries (e.g. ".so" files) to satisfy local imports (within the package), not just third-party imports (within site-packages).

Enhancement: Extended bidirectional type inference (expected types) to list comprehensions.

New Feature: Added new diagnostic rule "reportPropertyTypeMismatch" that verifies that the type of the input parameter to a property's setter is assignable to the return type of the getter.

Bug Fix: Fixed bug that caused a crash in the type checker in cases where type arguments were not provided to a few special-case built-in classes.

Bug Fix: Fixed a bug in the handling of generics that involve constrained TypeVars. The TypeVar matching logic was sometimes inappropriately specializing the type using the first constrained type.

Bug Fix: Added special-case handling in type checker for callers who request the type of an expression that happens to be a name used in a call expression to designate a named parameter. This isn't really an expression, so the code wasn't handling it correctly, but callers (such as the hover provider and the new semantic token provider) were assuming that it was safe. This resulted in incorrect "X is not defined" diagnostics being logged.

pyright - Published 1.1.66

Published by erictraut about 4 years ago

Enhancement: Improved completion suggestion behavior when the insertion point is between an identifier and an empty index (e.g. "f[]") or in the presence of a missing right square bracket (e.g. "f.[").

Behavior Change: Changed diagnostic related to type argument count to be controlled by the "reportGeneralTypeIssues" diagnostic rule. It was previously always emitted as an error.

From Pylance: Fix progress reporter type, auto-import/symbol changes, worker thread updates, improve auto-import tooltips (#977)

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Eliminated incorrect error when "super()" was used in a class where one or more parent classes were of an unknown type.

Bug Fix: Changed the handling of old-style comment method annotations to accept an optional annotation for "self" and "cls" parameters.

Bug Fix: Changed handling of dataclass classes that derive from a class whose type is unknown. The synthesized constructor now allows any parameter list in this case.

Enhancement: Improved completion provider to distinguish properties from other methods.

Behavior Change: Changed heuristics for function return type inference so methods that raise a NotImplementedError and have no other return path have an inferred return type of Unknown rather than NoReturn. Such methods should be marked as abstract, but frequently they are not.

Behavior Change: Changed the behavior of the import resolution logic to fail an import resolution of a multi-part name (e.g. "a.b.c") if it can't be fully resolved. This could produce false positives in cases where third-party libraries are using dynamic tricks to manipulate their package namespace, but it will eliminate false negatives.

Bug Fix: Suppress the use of "Unnecessary" diagnostic hints (used to display variables and code blocks in gray) if the LSP client claims not to support this tag.

Enhancement: Added new "reportMissingTypeArgument" diagnostic rule and enabled it by default in "strict" mode. It generates a diagnostic when a generic class or generic type alias is used in an annotation with no type arguments provided.

Bug Fix: Fixed handling of scopes for nested classes. The previous logic allowed an inner class to access variables defined in an outer class, which is not permitted.

Enhancement: Added check for raise statements that take an exception class but the class constructor requires one or more arguments.

Bug Fix: Fixed bug in tokenizer that cause line numbers to be off when an invalid token occurred at the end of a line.

Bug Fix: Fixed a bug in the Pyright parser. It was not correctly following the Python grammar spec when parsing type annotations, so it generated syntax errors in some cases where that was inappropriate.

Enhancement: Added a check and a general type diagnostic for metaclass conflicts.

pyright - Published 1.1.65

Published by erictraut about 4 years ago

Bug Fix: Fixed bug in command-line version that caused an error to be reported when "useLibraryCodeForTypes" or "verboseOutput" was specified in the pyrightconfig.json file.

Enhancement: Added support for protocol matching where the protocol includes an overloaded method.

Enhancement: Improved diagnostic messages for function type mismatches.

Enhancement: Improved diagnostic messages for tuple matching and union assignments.

Enhancement: Changed nested diagnostic messages to use non-breaking spaces so indentations are visible within the VS Code "Problems" panel.

Bug Fix: Fixed bug in reportIncompatibleMethodOverride diagnostic check. The logic was checking for wider parameter types when it should have been checking for narrower.

Bug Fix: Fixed bug in method override validation code. It wasn't applying partial specialization of the base class, resulting in inappropriate errors in some cases.

Bug Fix: Fixed bug in the type evaluation of expressions with + or - operators and integer literal operands. These expressions should evaluate to a literal type, not an int.

Bug Fix: Fixed bug in parsing of f-strings that contain \N escape and a Unicode character name that includes a hyphen.

Bug Fix: Fixed bug in type evaluator that caused an incorrect error when a class decorator was used for a generic class.

Bug Fix: (From Pylance) Fixed performance problem related to file change events triggered by reads from site-packages.

Enhancement: Enabled support for PEP 613 (TypeAlias).

Bug Fix: Fixed bug that caused type aliases to get expanded in some contexts when they shouldn't.

Bug Fix: Fixed bug that caused "from .A import *" to work incorrectly when the wildcard included symbol A.

Enhancement: Added logic in completion provider to return class variables in base classes when the insertion point is in the context of a subclass body.

Bug Fix: Fixed TypeAlias code to check for Python 3.10 rather than 3.9 since PEP 613 has been moved out to 3.10.

Enhancement: Added performance optimization for TypedDict classes. Entries are now computed once and cached in the class type. This provides a big speed-up for TypeDict classes that have a large number of fields.

Enhancement: Added performance optimization for union types that contain large numbers of string literals. The code for inserting new items into a union is O(n^2); this optimization makes it O(n) for string literal types.

Bug Fix: Fixed bug that caused custom import aliases of "Final", "Literal" and "TypeAlias" to not work correctly.

Bug Fix: Fixed bug that resulted in spurious errors when hovering over module names in import statements.

Bug Fix: Fixed several bugs relating to symbols introduced into a class by its metaclass.

Bug Fix: Fixed bug that caused type analyzer to crash when a nonlocal binding referred to a symbol that was not present in an outer scope and then was assigned to.

pyright - Published 1.1.64

Published by erictraut about 4 years ago

Bug Fix: Fixed regression that caused "isinstance(x, Callable)" to be flagged as an error when PEP 484 says that it's legal.

Enhancement: Changed error messages related to "partially unknown" types to expand type aliases, which can obscure the unknown part of the type.

Enhancement: Added support for narrowing types based on the pattern "A.B == " and "A.B != " when A has a union type and all members of the union have a field "B" with a declared literal type that discriminates one sub-type from another.

Enhancement: Added bidirectional type inference for ternary expressions.

Bug Fix: Fixed incorrect handling of member accesses when the accessed field had a type that was a union between two or more classes, some with special accessor methods (e.g. "get") and some without.

Enhancement: Improved type checking for assignments of callable types. Previously, certain edge cases were ignored.

Enhancement: Added code to check for overlapping (obscured) overload functions.

Bug Fix: Fixed bug that caused incorrect evaluation of type alias that refers to Literal types. The literal values were being stripped in some cases.

Bug Fix: Fixed recent regression that caused type aliases that described literal types to be printed incorrectly in hover text and error messages.

Enhancement: Added code to report overloads that overlap in an "unsafe" way — i.e. they can potentially accept the same arguments but return different (incompatible) types.

Enhancement: Updated typeshed stubs to latest version.

Bug Fix: Fixed bug in assignment checks between homogeneous multi-length tuples and fixed-size tuples.

pyright - Published 1.1.63

Published by erictraut about 4 years ago

Enhancement: Diagnostic rule severity overrides are now editable in the VS Code settings UI.

Bug Fix: Fixed out-of-memory error that occurred during a workspace "find symbols" operation. We were not properly checking for the heap high watermark during this operation.

Enhancement: Added support for special type "Counter" exported by typing module, which is an alias for collections.Counter.

Bug Fix: Fixed bug in bidirectional type inference for dictionary statements. The logic was not allowing for dict subclass Mapping.

Enhancement: Improved type checker's handling of "in" operator. It previously flagged an error if the right operand didn't support a __contains__ method. It now properly checks for iterable types as well.

Bug Fix: Fixed bug that caused incorrect evaluation of symbol types within a chain of assignments (e.g. "a = b = c = 4") in some cases.

Enhancement: Enabled file watcher for libraries to detect changes in installed packages. This behavior is already standard for Pylance, but it was disabled for Pyright.

Enhancement: Improved handling of Tuple type. The type checker now does a better job retaining the types of the individual elements within a Tuple or a class that derives from a Tuple.

Enhancement: Improved support for NamedTuple classes and classed derived from NamedTuple. The type checker now retains types of individual elements when used with unpacking and indexing operators.

Behavior Change: Changed "find workspace symbols" to return only symbols from within user code or opened files, not library files that are closed.

Bug Fix: Fixed recent regression that caused incorrect errors to be generated in sub files for certain call expressions.

New Feature: Added support for Concatenate as described in latest version of PEP 612. Added ParamSpec and Concatenate to typing.pyi.

pyright - Published 1.1.62

Published by erictraut about 4 years ago

Bug Fix: Fixed bug in the handling of unrecognized escape sequences within string literals.

Bug Fix: Fixed bug related to a subtle interaction between bidirectional type inference of list expressions that contain literal values and TypeVar matching. The previous logic was incorrectly matching T in List[T] and the list contained a literal type. It should have stripped the literal if possible.

Enhancement: Added diagnostic message for TypeVar with a single constraint type for consistency with mypy.

Enhancement: Added support for member access completion suggestions when the LHS is a function or a None type.

Behavior Change: Behavior change for type stub generator: don't emit __all__ assignments or assignments to self.xxx in function bodies. These violate PEP 484 guidelines for type stubs.

Enhancement: Added diagnostic check to reportInvalidStubStatement that flags parameter default value expressions that are not "..." in stub files.

Bug Fix: Fixed bug that caused annotated types of vargs and kwargs parameters not to be printed in hover text.

Enhancement: Implemented support for older-style function annotation type comments. I previously resisted adding this additional complexity, but we're seeing many libraries that still contain these annotations for backward compatibility with Python 2.

Bug Fix: Fixed bug that caused a crash in the type analyzer when a protocol class referred to itself.

Enhancement: Added support for "useLibraryCodeForTypes" option in config file. It overrides the client setting of the same name or the "--lib" command-line option.

Bug Fix: Fixed several bugs in logging for config errors.

Enhancement: Added logic to type checker to validate that the "self" or "cls" parameter with a specified type annotation is assignable when binding the method to an object or class.

Enhancement: Improved type assignment diagnostic message. Added "(property)" designator to the end of a property type to differentiate it from a normal attribute.

Enhancement: Added code to validate that method overloads are all abstract or not.

Enhancement: Updated typeshed stubs to the latest.

pyright - Published 1.1.61

Published by erictraut about 4 years ago

Bug Fix: Fixed bug that caused symbols to be marked unaccessed if they were accessed by code that is not accessible (e.g. due to conditional execution based on the platform).

Bug Fix: Updated PEP 604 and PEP 612 error message to refer to Python 3.10 instead of 3.9.

Behavior Change: Changed logic that validates "self" or "cls" parameter names to ignore the check if the provided parameter name begins with an underscore, as is seen in several typeshed stub files.

Bug Fix: Fixed bug in nested f-string parsing when f-string contains triple quotes that include single quotes.

Bug Fix: Fixed handling of a class that is subclassed from both Enum and another class (like str).

Enhancement: Added support for generic classes that refer to themselves as type arguments within their base class.

Bug Fix: Improved error message for partially-unknown types that have a type alias.

Bug Fix: Allow use of forward-declared classes as subclass in class declarations within type stub files.

Bug Fix: Add special-case handling of __class_getitem__ method, which acts as a class method even though it is not decorated as such.

Bug Fix: Added missing validation of arguments to type call.

Enhancement: Added = character to end of named parameter for completion suggestions within a call signature.

Bug Fix: Added client capability check for signature information "labelOffsetSupport" for compatibility with clients that don't support this capability.

Bug Fix: When adding completion suggestions to the list for expression completion, avoid adding duplicately-named symbols that appear in nested scopes.

Bug Fix: Fixed bug related to calls of methods on a metaclass via classes that are constructed by that metaclass.

Enhancement: Added check for single @overload function with no additional overloads.

pyright - Published 1.1.60

Published by erictraut about 4 years ago

Bug Fix: Fixed a bug "aliased import with leading underscore produces private usage error".

Bug Fix: Fixed a bug that caused the wrong diagnostic message string to be used when "Generic" is used with no type arguments.

Enhancement: Added new diagnostic message for when "Generic" is used in contexts outside of a class definition statement.

Bug Fix (from Pylance): Use sys.version_info to query interpreter version.

Enhancement: Added heuristics to type var solver so it picks the "least complex" solution when considering the elements within a union.

Enhancement: Updated typeshed stubs to the latest versions.

Bug Fix: Fixed a bug that caused an error to be reported when a newline token was used within an f-string expression.

Enhancement: Added new diagnostic rule "reportInvalidStubStatement" (on by default in strict mode, off otherwise) that reports diagnostics for statements that should not appear within a type stub file.

Enhancement: Added diagnostic for a module-level __getattr__ function defined in a type stub file when in strict mode.

Bug Fix: Fixed bug that caused imports (and other symbols) to be reported as unaccessed if they were accessed from within code that was deemed to be unreachable (e.g. due to the current platform configuration).

Behavior Change: Changed logic for reportUnusedClass and reportUnusedFunction diagnostic rules so they don't report private-named functions and classes within stub files.

Bug Fix: The token "..." should mean an ellipsis object, not the ellipsis class, when used in a normal expression within a non-stub file.

Enhancement (from Pylance): Add python.analysis.autoImportCompletions to control auto-import completions.

pyright - Published 1.1.59

Published by erictraut about 4 years ago

Bug Fix: Changed the inferred type of an async function to use Coroutine rather than Awaitable type. Coroutine is a subclass of Awaitable and is arguably more correct in this case.

Bug Fix: Fixed a bug in the handling of position-only parameters with default values followed by named parameters or **kwargs.

Bug Fix: Fixed a bug where "yield from" argument was assumed to be an "Iterator", but it should really be an "Iterable".

Bug Fix: Fixed bug where "from .A import A" statement caused symbol "A" to have an inferred type that was a union of a module and other type, even though the other type immediately overwrites the module.

Behavior Change: Changed type stub generator to never generate parameter type annotations based purely on default value types since those can be incorrect or incomplete. Changed type stub generator to automatically add method return types for common magic methods whose return type is always the same.

Behavior Change: Changed type stub generator to avoid emitting functions and methods that begin with an underscore.

Enhancement: Changed type checker to flag unaccessed symbols within type stubs in some cases. It doesn't mark function parameters or variables as unaccessed, and it doesn't mark imports of the form "from x import y as z" or "import a as b" as unaccessed since those are intended to be re-exports.

Enhancement: Changed type checker to treat "..." as an "Unknown" type when used as the RHS of an assignment statement such as "a = ...". This idiom appears sometimes within type stubs, and it should be treated as a missing (unknown) type so stub authors know that they need to fill in a type annotation.

Enhancement: Improved the diagnostic message used to report parameter type mismatches when a parameter name isn't known.

Bug Fix: Fixed a bug whereby a TypeVar in a source type could be conflated with a same-named TypeVar in a dest type when performing TypeVar matching.

Bug Fix: On the Windows platform, avoid calling 'python3' to determine the import paths for the current interpreter. This command can sometimes display a dialog indicating that python isn't installed and can be downloaded from the store.