Commit Graph

3525 Commits

Author SHA1 Message Date
Eric Traut
46c6484ed6 Fixed bug that resulted in incorrect type checking behavior when a type annotation involved a tuple with literal elements. 2021-06-03 14:49:33 -07:00
Eric Traut
f9129cb216 Changed reveal_type and reveal_locals to expand type aliases in their output. 2021-06-03 10:47:56 -07:00
Eric Traut
fc173ffcc4 Changed type printer to handle recursion differently — most notably when dealing with recursive type aliases. If it is asked to expand type aliases, it now expands only the first level of a given type alias, so if there's recursion, it will use the type alias name the second time it is encountered rather than continuing to expand it. 2021-06-03 10:44:26 -07:00
Eric Traut
3053ff314c Closed a hole in type narrowing for "in" operator when used with TypedDict. It can eliminate types from a union only if the type is marked final. 2021-06-02 21:26:14 -07:00
Eric Traut
b50f272f5b Added check for an attempt to instantiate a protocol class. This causes a runtime error. 2021-06-02 21:11:35 -07:00
Eric Traut
209c80409e Published 1.1.146 2021-06-02 12:58:23 -07:00
Jake Bailey
e52d1e96e5
Typecheck JS, webpack caching, zip/egg support (#1937) 2021-06-02 12:18:10 -07:00
Eric Traut
45390e6fbe Fixed bug in pattern matching logic for class patterns where the class uses properties or descriptors for the targeted attributes. 2021-06-01 21:12:50 -07:00
Eric Traut
b4d11bcbe6 Enhanced logic to detect unannotated decorator functions and treat them as no-ops rather than using return type inference, which often leads to incorrect and confusing results for decorators. 2021-06-01 20:36:29 -07:00
Eric Traut
d8ba4e4420 Changed call expression evaluation logic to not skip return type inference when there are errors detected during argument expression evaluation. This was previously added as an optimization, but it was leading to confusing results in some cases. 2021-06-01 20:35:28 -07:00
dependabot[bot]
c72240fa34
Bump ws from 7.4.5 to 7.4.6 in /packages/pyright-internal (#1923)
Bumps [ws](https://github.com/websockets/ws) from 7.4.5 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.4.5...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eric Traut <eric@traut.com>
2021-06-01 11:22:06 -07:00
Eric Traut
c66d67ed84 After further experimentation, made class attribute __module__ accessible through a class instance. 2021-05-31 20:17:04 -07:00
Eric Traut
c7eb306b20 Added support for __qualname__ and __module__ attributes within a class body. 2021-05-31 20:09:01 -07:00
Eric Traut
d460632443 Added optimization for union creation where all subtypes are the same. This optimization commonly reduces the need to create new types during code flow operations. It also retains type alias info more faithfully. 2021-05-31 12:59:41 -07:00
Eric Traut
14f39f1094 Fixed false positive error indicating that a type alias is a variable. This results when a type alias refers to a union and that union is reformed when losing the original type alias. 2021-05-31 12:52:02 -07:00
Eric Traut
c64ee8272c Updated reportIncompatibleVariableOverride to avoid reporting an error when a class variable is reassigned a value in a base class without declaring its type. 2021-05-30 20:45:41 -07:00
Eric Traut
af23c4dbf5 Updated to the latest version of typeshed stubs. 2021-05-30 16:08:56 -07:00
Eric Traut
79ce1f7a93 Published 1.1.145 2021-05-30 11:00:19 -07:00
Eric Traut
d6d41a377b Changed the way conditional constraints are tracked in the type evaluator. This is a significant change that simplifies the logic and handles some cases that the old approach did not. 2021-05-30 10:55:59 -07:00
Eric Traut
574f71f858 Augmented type checking logic for generator expressions to allow await keyword even though enclosing function isn't async. Also allowed generator expression to be evaluated as AsyncGenerator rather normal Generator. 2021-05-29 17:22:31 -07:00
Eric Traut
0f9d308827 Added documentation for conditional types reported with "*". 2021-05-29 15:43:09 -07:00
Eric Traut
8acded1344 Changed type printer to include a "*" after a type if it is conditionally associated with a TypeVar constraint. 2021-05-29 15:13:14 -07:00
Eric Traut
99ad5afc71 Improved detection and reporting of illegal type alias recursion cases — e.g. when a possible type alias refers to a function that uses the type alias in parameter or return type annotations. 2021-05-29 15:08:39 -07:00
Eric Traut
65f4ab3ee0 Fixed bug that can result in a crash when indexing a file that includes a nested function or lambda that is used for type inference. 2021-05-29 12:23:26 -07:00
Eric Traut
7abf56c9c7 Fixed bug in code flow engine where it was sometimes evaluating the wrong type when cycles occurred in type dependencies. 2021-05-29 11:57:09 -07:00
Eric Traut
dbcf5cc077 Changed type variable constraint solver to preserve literal types when matching type arguments from other class types. In other cases, it typically "strips" the literal, widening the type to a str, int, etc. This change allows proper type evaluation in certain cases where a literal type is specified in a type annotation, such as with Set[Literal["foo"]]. 2021-05-29 09:28:29 -07:00
Eric Traut
21a0655397 Removed false positive error reported for a "bare" raise statement outside of an except clause. 2021-05-29 08:09:04 -07:00
Eric Traut
e4c077ed5a Fixed broken unit tests. 2021-05-28 21:53:25 -07:00
Eric Traut
03514d67f1 Enhanced type stub generator to emit inferred function and method return types as comments. 2021-05-28 21:39:48 -07:00
Eric Traut
f0e8c627cb Enhanced type stub generator so it doesn't emit "object" as base class, since that's implied in Python 3.x. 2021-05-28 21:39:24 -07:00
Eric Traut
685b3b5392 Added logic to handle the case where a dataclass subclass overrides a member of its parent class with a ClassVar and another dataclass then subclasses from the child. 2021-05-28 20:01:53 -07:00
Eric Traut
2f8cf878c9 Enhanced "reportIncompatibleVariableOverride" diagnostic check to detect the case where a base class declares a class variable and a child class tries to override it with an instance variable or vice versa. 2021-05-28 19:49:10 -07:00
Eric Traut
aa01b17e8c Changed the logic that validates the assignment to instance variables that are marked Final. Previously, only one such assignment was allowed even if it was within an __init__ method. It now allows an arbitrary number of assignments (conditional or otherwise) as long as they occur within an __init__ method. 2021-05-28 14:44:12 -07:00
Eric Traut
6235e808f3 Improved handling of call expressions where the call is a union and some of the subtypes return NoReturn and others do not. 2021-05-28 13:16:32 -07:00
Eric Traut
e7cc4c9831
Avoid reanalyzing a file when it is opened in the editor if we have already analyzed it and the file contents are the same as before. This restores the behavior that existed prior to this change: 2d90df325f (diff-32dc01623d13bd967864d6e0b14c73f5e490534e7bb337a1d182169b8c670a79R426). (#1918)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-05-28 11:42:38 -07:00
Eric Traut
9e02e24f92 Fixed style issue. 2021-05-27 18:00:44 -07:00
Eric Traut
b411745bf9 Fixed bug that resulted in the incorrect type when bidirectional type inference (an "expected type") was used in conjunction with the tuple() constructor. 2021-05-27 16:44:41 -07:00
Eric Traut
fd3343028b Published 1.1.144 2021-05-26 15:03:25 -07:00
Jake Bailey
e8407286b5
Drop unused parse trees in indexing step, small refactorings (#1913)
Co-authored-by: HeeJae Chang <hechang@microsoft.com>
2021-05-26 14:21:08 -07:00
Eric Traut
042084ee1a Simplified type printer logic for unions. 2021-05-26 13:12:41 -07:00
Eric Traut
39152459f3 Improved error message consistency for for "cannot assign to None" condition. 2021-05-26 11:49:24 -07:00
Eric Traut
dd1e238ef4 Fixed false positive error in check for inappropriate use of contravariant type var in return type annotation. It should not generate an error when the contravariant type var is part of a union. 2021-05-26 11:19:58 -07:00
Eric Traut
5dd355afd2 Fixed bugs that prevented ParamSpec annotations P.args and P.kwargs from working properly when the annotation was in quotes. 2021-05-26 09:41:02 -07:00
Eric Traut
42a727366f Fixed bug in specialization of generic class that contains only one type variable that is a ParamSpec. 2021-05-25 13:36:02 -07:00
Eric Traut
5f0b44ec34 Fixed bug in logic that converts a type into a text representation. It wasn't properly adding the scope for a ParamSpec in certain circumstances, so instead of outputting P@scope, it was outputting P. 2021-05-25 12:52:35 -07:00
Eric Traut
e9cbef254f Fixed bug caught by tests. 2021-05-25 11:21:34 -07:00
Eric Traut
0637977643 Improved error message for missing **kwargs parameter when assigning one function to another. 2021-05-25 09:54:56 -07:00
Eric Traut
36a589d9dd Added error for keyword-only parameter separator or position-only parameter separator appearing in a function signature after an "*args" parameter. This will result in a runtime error. 2021-05-24 20:32:16 -07:00
Jake Bailey
173fd1b978
Don't use process.exit in CLI to prevent truncated stdout (#1905) 2021-05-24 11:20:28 -07:00
Eric Traut
98d7b61625 Published 1.1.143 2021-05-23 23:51:29 -07:00