Commit Graph

4166 Commits

Author SHA1 Message Date
Eric Traut
c71001e4ed Improved error message for unknown or partially-unknown type arguments in package type verifier. 2021-11-30 21:22:49 -08:00
Eric Traut
3a9c610826 Fixed a bug in ternary expression type evaluation that resulted in a false positive error. It was not properly handling the case where the condition was statically determined to be false or true. 2021-11-30 21:07:15 -08:00
Eric Traut
e70e69e7a1
Sped up "find reference" by performing a quick text search for the re… (#2641)
* Sped up "find reference" by performing a quick text search for the reference symbol and avoiding additional work for that file if there is no chance of finding a reference within it.

* Avoid parsing the file if its contents don't contain the reference symbol text.

Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-11-30 20:32:33 -08:00
Eric Traut
ced49848a6 Fixed misleading error message involving a type mismatch within the TypeVar constraint solver. The source and destination types were reversed. 2021-11-30 19:57:29 -08:00
Eric Traut
28d60e62ae Updated command-line documentation for consistency. 2021-11-29 22:31:14 -08:00
Eric Traut
fbb755036e Published 1.1.191 2021-11-29 22:29:55 -08:00
Eric Traut
52c22989ae Changed typeVarTransform logic from a function to a class for future flexibility; no functional change. 2021-11-29 21:28:39 -08:00
Eric Traut
bffa63f5a5 Small code simplification, no functional change. 2021-11-29 20:33:17 -08:00
Eric Traut
541ddcb935 Changed parse error messages related to unclosed parentheses, braces and brackets so they are reported at the location of the starting token to better match the new Python 3.10 parse error reporting behavior. 2021-11-29 13:35:24 -08:00
Jos Verlinde
8d32784230
extend documentation on JSON (#2635)
copying the information provided as answer to https://github.com/microsoft/pyright/issues/2634
2021-11-29 13:20:41 -08:00
Eric Traut
cae15781a3 Enhanced truthy/falsy type narrowing pattern to handle classes that contain a __bool__ method that always returns True or False. 2021-11-28 02:52:39 -08:00
Eric Traut
3ff69a1ffc Fixed bug in "--ignoreexternal" mode of "--verifytypes" feature. It was not properly flagging errors when the type was external (and known) but the type arguments were partially unknown. 2021-11-28 01:59:05 -08:00
Eric Traut
04d1bcf9f5 Fixed bug that resulted in a false positive error when using class pattern matching with type variables. 2021-11-28 01:34:05 -08:00
Eric Traut
880efb3ca7 Fixed a hole in the check for partially-unknown types. Generic type aliases that are not specialized or are partially specialized (i.e. only some type arguments are specified) should trigger this check. 2021-11-27 17:41:04 -08:00
Eric Traut
ed84eb7b36 Changed reportPropertyTypeMismatch to be disabled by default in all diagnostic modes. 2021-11-27 17:08:01 -08:00
Eric Traut
96030b2961 Exempted class symbol __weakref__ from type completeness check since its type is well defined by the Python spec. 2021-11-27 16:52:49 -08:00
Eric Traut
f714e092a0 Updated dataclass_transform documentation to reflect Python 3.10 changes. 2021-11-27 15:50:31 -08:00
Eric Traut
4d4dd8858c Added special-casing to suppress "partially unknown type" diagnostic within member access expressions when they are used to access non-specialized generic classes within an argument expression. There are legitimate uses of partially unknown types in this case (e.g. in "isinstance" calls). 2021-11-26 11:36:44 -08:00
Hubert
736e41c63c
Added keyword-only check to dataclasess __match_args__ (#2615)
* Add keyword-only check to dataclasess `__match_args__`

* Fixed tests added in add keyword-only check to dataclasess `__match_args__`
2021-11-25 11:13:26 -08:00
Eric Traut
b269ee9a85 Published 1.1.190 2021-11-24 18:43:33 -08:00
Eric Traut
a3dee52702 Changed logic that determines whether a function should be exempt from return type consistency checks. If a function or method contains only a docstring but no ..., it is no longer exempt (unless it is an @overload). 2021-11-24 17:16:28 -08:00
Eric Traut
7184425c47 Further improved check for inconsistent use of tabs and spaces to catch a previously-unreported case that generates runtime errors. This change handles inconsistent dedents. 2021-11-24 17:02:12 -08:00
Eric Traut
280d95cd80 Updated documentation for reportUnusedVariable. 2021-11-24 16:05:53 -08:00
Eric Traut
ced19cbcbd Changed reportUnusedVariable diagnostic check to exempt variables whose names begin with an underscore. 2021-11-24 16:04:57 -08:00
Eric Traut
3e8101bcd0 Added a type consistency check for TypedDicts which are otherwise compatible except that one is marked @final and the other is not. 2021-11-24 15:36:57 -08:00
Eric Traut
481f02a7cc Improved check for inconsistent use of tabs and spaces to catch a previously-unreported case that generates runtime errors. 2021-11-24 15:32:13 -08:00
Eric Traut
7f4b0b0036 Updated typeshed stubs to the latest. 2021-11-24 10:39:01 -08:00
Eric Traut
cd3892c059 Fixed bug that resulted in unreported Unknown type in strict mode when the type was evaluated as part of a call to an overloaded function in some circumstances. 2021-11-24 10:38:40 -08:00
Eric Traut
8dc3b1da12 Fixed style issues. 2021-11-23 20:29:09 -08:00
Eric Traut
4353a33151 Fixed bug that prevented error when a generator function returned an inappropriate type if that type was a subclass of Iterable. 2021-11-23 20:20:19 -08:00
Eric Traut
86a975da16 Added support for async functions that return NoReturn type. 2021-11-23 04:29:54 -08:00
Eric Traut
795a37f624 In the case where a type annotation is an illegal form (e.g. a variable or a function), the annotation should evaluate to an Unknown type. 2021-11-23 03:01:03 -08:00
Eric Traut
100029a3ff Fixed bug that caused false positive when evaluating type compatibility between two TypedDict types that are structurally the same but have different declarations. PEP 589 indicates that these should be treated as compatible types. 2021-11-22 14:10:37 -08:00
Eric Traut
58465482e2 Published 1.1.189 2021-11-21 23:11:49 -08:00
Eric Traut
5408336cc8 Made illegal assignment target checks unconditional so they are not gated by reportGeneralTypeIssues. These should be treated more like parse errors than type checking errors. 2021-11-21 15:29:08 -08:00
Eric Traut
f70ed1a8ce Fixed a hole in the type checking logic for TypedDict classes. It was not properly handling the invariant case. 2021-11-21 13:39:15 -08:00
Eric Traut
3a19ac435d Fixed bug in code flow engine that caused incorrect determination of node reachability in cases where an unannotated function recursively called itself. 2021-11-20 12:12:01 -08:00
Eric Traut
f70318dd29 Fixed false positive error when using a union type expression in an isinstance or issubclass call on Python 3.10. 2021-11-19 20:29:07 -08:00
Eric Traut
ec5c68f18f Added checks for illegal forms of Literal type arguments. 2021-11-19 19:33:39 -08:00
Eric Traut
be7872f834 Fixed bug that caused incorrect type evaluation of parameter with implied Optional type based on None default argument value when strictParameterNoneValue setting is false. 2021-11-19 19:22:14 -08:00
Eric Traut
be6c748007 Fixed recent regression in import resolver that caused a local import to no longer be preferred over an installed module by the same name. 2021-11-19 17:28:02 -08:00
Eric Traut
cfc07ef20f Fixed crash that occurred when specializing a class with a TypeVarTuple and failing to provide a type argument for the TypeVarTuple type parameter. 2021-11-18 19:29:35 -08:00
Eric Traut
5a2c9435b5 Added strings to some asserts in sourceFile to help root cause a few crashes we're seeing in the pylance telemetry. 2021-11-18 09:33:13 -08:00
Eric Traut
bda1e0b822 Fixed regression relating to type inference for non-generic classes that have unannotated constructors (so-called "pseudo-generic classes"). 2021-11-17 23:03:51 -08:00
Eric Traut
15d6cb74ce Published 1.1.188 2021-11-17 22:40:54 -08:00
Eric Traut
e02c3aaef4 Implemented diagnostic check for a ClassVar declaration that uses a type variable. PEP 526 explicitly states that this is not allowed. 2021-11-17 22:37:44 -08:00
Heejae Chang
121c8081c5
Use shared helper method to call python interpreter to have consistent behavior between different calls. (#2581) 2021-11-17 21:59:51 -08:00
Eric Traut
ab4d96f8a0 Fixed type checking hole (false negative) in certain circumstances involving loop constructs and variables whose types are modified within these loops. This bug fix also has a positive performance impact when analyzing functions with complex code flow graphs. 2021-11-17 19:55:44 -08:00
Eric Traut
4f13222244 Improved handling of binary and unary operation evaluation when one of the operands is a "Never" type. 2021-11-17 19:49:40 -08:00
Eric Traut
7d430c45ba Added incomplete type tracking for unary operations. 2021-11-17 19:32:16 -08:00