Eric Traut
07f39d6329
Added logic to convert Type[A | B]
into Type[A] | Type[B]
, which avoids violating assumptions elsewhere in the type checker.
2021-06-10 15:04:40 -07:00
Eric Traut
afca267308
Added error handling for very large source files. This situation is n… ( #1973 )
...
* Added error handling for very large source files. This situation is now detected earlier so we don't attempt to load the file contents and crash the language server in the process.
* Moved file length check into timing wrapper so stat check is treated as part of the file read operation.
Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-06-10 13:54:45 -07:00
Eric Traut
3a618762a9
Fixed style issue
2021-06-10 11:13:23 -07:00
Eric Traut
d2bdd1b0c8
Fixed bug in type checker related to the use of a TypeVar or ParamSpec within an inner function when it is already bound to an outer function but used only within that outer function's return type annotation.
2021-06-10 11:06:40 -07:00
Eric Traut
a98d4a7e0e
Tweaked heuristics in constraint solver for dealing with matching of TypeVar T for the type expression Union[T, SomeClass[T]]
. There are two valid solutions if the argument is type SomeClass[X]
, but the "simpler" solution (T = X
) should be preferred over the more complex (T = SomeClass[X]
).
2021-06-09 18:34:54 -07:00
Eric Traut
a2d7c96d54
Added check for illegal use of "async" keyword. The Python interpreter generates a syntax error if it is used outside of an async function.
2021-06-09 17:48:01 -07:00
Eric Traut
a0b4f2e4b7
Fixed bug that caused false positive error when using a generic type alias as a constructor call.
2021-06-09 17:15:11 -07:00
Jake Bailey
e3f7cccc6e
libzip fixes, change function to protected in resolver, make watcher error a warning ( #1967 )
...
Co-authored-by: HeeJae Chang <hechang@microsoft.com>
2021-06-09 13:30:11 -07:00
Eric Traut
e98146b5d3
Published 1.1.148
2021-06-09 11:01:01 -07:00
Eric Traut
268421787d
Fixed a bug in the type checker relating to the use of a specialized generic class that is parameterized by a ParamSpec.
2021-06-09 10:54:17 -07:00
Eric Traut
d7cb61db81
Fixed bug in type checker when handling Final variables assigned at the class level. PEP 591 indicates that they should be treated as though they are annotated as ClassVar even though they are not.
2021-06-09 10:25:21 -07:00
Eric Traut
6caa0d77e8
Fixed bug in type checker relating to constrained type variables that combine non-union and union constraints.
2021-06-08 13:39:19 -07:00
Eric Traut
efa07cdfbc
Fixed bug that resulted in a false positive error when using generic Type[T]
in a function parameter in overload validation.
2021-06-07 17:52:59 -07:00
Eric Traut
e9c5e9118b
Fixed style issue
2021-06-07 17:34:31 -07:00
Eric Traut
7d33b84d43
Fixed bug in type printer that resulted in double parentheses around return type expressions when they involved unions.
2021-06-07 17:25:41 -07:00
Eric Traut
6110e4f89a
Fixed recent regression that resulted in a false positive error when instantiating a variable of type Type[T]
where T
was a protocol class.
2021-06-07 17:25:08 -07:00
Yuichi Tateno (secon)
e09560c3ea
Fixing wrong type int
to str
of type-concepts.md ( #1958 )
2021-06-07 15:53:48 -07:00
Eric Traut
029eb2c869
Fixed bug that resulted in false positive error when second argument to NewType
call contained a Type
object.
2021-06-07 13:36:14 -07:00
Eric Traut
ec478e68de
Fixed bug that caused parser error when handling a carriage return within a triple-quoted inner string within an outer triple-quoted f-string.
2021-06-06 08:03:13 -07:00
Eric Traut
31211e3666
Improved type checking for classes that are assigned to Callable
types. Previously, type incompatibilities were not reported if the __init__
or __new__
methods were overloaded within the class.
2021-06-05 22:18:03 -07:00
Eric Traut
1f07395733
Fixed recent regression that resulted in false positive errors when attempting to instantiate tuple
or type
directly.
2021-06-05 19:35:47 -07:00
Eric Traut
3c10e8566b
Added support for pattern matching exhaustion detection in cases where there is not an explicit irrefutable pattern present.
2021-06-05 12:26:25 -07:00
Eric Traut
250a6f5a31
Improved type narrowing of subject expression in a match statement when none of the case statements match the pattern and the code falls through the bottom of the match.
2021-06-05 11:39:13 -07:00
Eric Traut
71c7bb1fe1
Published 1.1.147
2021-06-04 17:17:36 -07:00
Eric Traut
7fa4116ee2
Updated to the latest typeshed stubs.
2021-06-04 17:16:29 -07:00
Eric Traut
7929989538
Improved hover text for type variables and param specs by updating the label so they are not shown simply as type aliases.
2021-06-04 11:52:23 -07:00
Eric Traut
938fd6faac
Improved support for generic functions that annotate a parameter and a return type with a union that includes a TypeVar. In such cases, the TypeVar may not be matched during constraint solving.
2021-06-04 09:02:41 -07:00
Eric Traut
b4e661359e
Added diagnostic for an attempt to instantiate a special type like a Union, Callable, or Optional.
2021-06-03 21:15:05 -07:00
Eric Traut
66db4b12e5
Fixed bug that affected the handling of a function decorator that uses ParamSpec when applied to a classmethod or staticmethod.
2021-06-03 17:29:46 -07:00
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