Commit Graph

3877 Commits

Author SHA1 Message Date
Jake Bailey
d2771b18a8
Sync from Pylance (#2329)
Co-authored-by: Bill Schnurr <bschnurr@microsoft.com>
Co-authored-by: HeeJae Chang <hechang@microsoft.com>
2021-09-22 14:26:36 -07:00
Eric Traut
e5d43dc4f3 Fixed style issue 2021-09-22 10:37:58 -07:00
Eric Traut
510f3c0e40 Added logic to report a diagnostic if an instance variable is assigned only via an augmented assignment expression. 2021-09-22 10:21:24 -07:00
Eric Traut
1024fbfa72 Changed type evaluation behavior for protected instance variables (those that begin with a single underscore) and are assigned a literal value. Previously, the literal type was retained if the reportPrivateUsage was enabled. This caused various problems. It was a bad idea because type evaluations should not differ based on diagnostic reporting switches. 2021-09-22 10:20:32 -07:00
Eric Traut
073a914331 Fixed bug where a class whose constructor is unannotated was allowed to have explicit generic type arguments. 2021-09-22 08:33:06 -07:00
Eric Traut
176a01bd3b Fixed style issue 2021-09-22 01:02:52 -07:00
Eric Traut
d07a64e733 Fixed bug in synthesized __new__ method for NamedTuple class that caused the constructor of subclasses of the NamedTuple to construct the base class. 2021-09-22 00:39:00 -07:00
Eric Traut
8057c63bc1 Fixed typo in comment. 2021-09-21 16:50:58 -07:00
Jake Bailey
b5f2dc2801
Update CodeQL to match new template (#2323) 2021-09-21 13:33:34 -07:00
Eric Traut
16aafe4d39 Fixed bug in TypeVarTuple support that prevented the use of an unpacked TypeVarTuple within a type argument list for types other than Tuple or Union. 2021-09-21 00:49:56 -07:00
Eric Traut
172211b57d Published 1.1.170 2021-09-20 22:30:29 -07:00
Eric Traut
0866251fcd Updated typeshed stubs to the latest 2021-09-20 20:01:25 -07:00
Eric Traut
d23bb306e4 Allow symbols that are not explicitly re-exported from a stub to be imported into another stub. This change is required to support recent updates to typeshed. 2021-09-20 20:00:57 -07:00
Eric Traut
ed0c17f259 Fixed bug that resulted in false positive when using unpack operator with self when self refers to a named tuple or a tuple with known length. 2021-09-20 18:02:26 -07:00
Eric Traut
0e9d7f2d60 Fixed infinite recursion bug in hover provider when a symbol referred to both a locally-defined class and an imported symbol. 2021-09-20 08:30:30 -07:00
Eric Traut
af4deba83d Fixed bug that resulted in false negative when bidirectional type inference involved an "expected type" of Any and the type being evaluated was a call expression that returned a generic object as a return value. 2021-09-20 08:08:28 -07:00
Eric Traut
e49e0ff6d9 Fixed false negative error in parser where it did not correctly detect a syntax error when a walrus operator was used in a ternary operator condition expression. 2021-09-19 22:48:44 -07:00
Eric Traut
c787bf4d72 Fixed bug in handling of ParamSpec within callback protocol when the signature includes a position-only or keyword-only separator. 2021-09-19 15:21:56 -07:00
Eric Traut
232f22e13b Added support for ParamSpec matching when used within a callback protocol. PEP 612 is unclear on whether this should be supported, by pyre (the reference implementation for the PEP) does support it. 2021-09-19 14:21:31 -07:00
Eric Traut
e6a20837b1 Fixed false positive error where an exception class (as opposed to an exception object) is used in a "from" clause in a "raise" statement. 2021-09-18 20:22:50 -07:00
Eric Traut
15d4d29fdc Fixed style issue. 2021-09-18 00:29:25 -07:00
Eric Traut
90c1d14f36 Moved dataclass transform logic into dataClasses.ts module. 2021-09-18 00:08:00 -07:00
Eric Traut
5065073cbc Moved pattern matching logic out of typeEvaluator into its own module. 2021-09-17 23:54:35 -07:00
Eric Traut
bed32f2fe0 Moved type guard logic out of typeEvaluator into its own module. 2021-09-17 23:07:04 -07:00
Eric Traut
b834a7b9e3 Moved TypedDict functionality out of typeEvaluator into its own module. 2021-09-17 22:26:52 -07:00
Eric Traut
3cb70a78c7 Moved dataclass-related functionality out of typeEvaluator into its own module. 2021-09-17 22:06:04 -07:00
Eric Traut
ab6bf179b3 Removed remaining use of logInternalCall within typeEvaluator. 2021-09-17 21:49:10 -07:00
Eric Traut
d0e1a013c3 Moved named tuple class creation logic out of type evaluator into its own module. 2021-09-17 21:41:20 -07:00
Eric Traut
ee5f8600e2 Moved public type evaluator types to their own file in an attempt to start to break up the monster. 2021-09-17 20:58:18 -07:00
Eric Traut
057878fd8d Fixed false positive error when namedtuple constructor is called with a list of field names that includes dynamic (non-literal) expressions. 2021-09-17 20:37:17 -07:00
Eric Traut
2a9617c36c Improved isinstance and issubclass narrowing to handle open-ended tuples passed as the second argument. 2021-09-17 11:17:05 -07:00
Eric Traut
14ad02575f Extended reportCallInDefaultInitializer diagnostic check to disallow list, set or dict expressions in default argument expression. 2021-09-16 21:22:31 -07:00
Eric Traut
209e9283ca Improved member access logic to more faithfully match the Python interpreter's behavior when the member is assigned through a class, that member is a class itself, and that class has a metaclass that implements a descriptor protocol. It appears that the interpreter does not call through to the metaclass's __set__ method in this case, even though it does call its __get__ method when the member is accessed in the same circumstance.
Changed behavior of member accesses when the member is a class whose metaclass cannot be established (e.g. because it inherits from a class whose type is unknown). In this case, the previous logic returned an Unknown type for the member access. It now assumes that the metaclass does not implement a descriptor protocol, so it doesn't attempt to apply a descriptor access.
2021-09-16 18:35:05 -07:00
Jake Bailey
eca6f1a5c9
Sync from Pylance (#2309)
Rollup of:

- Update dependencies; TS 4.4, Prettier 2.4
- Explicitly handle unrooted execution environments (e.g., open file mode), preventing various crashes and oddities.
- Generate default values in method overload signatures. Previously, we didn't include them, which generated the wrong signature.
- Disable webpack caching (which recently broke upstream).
- Use attribute docstrings for type aliases in completion and hover.
- Clean up import resolver search path cache, which was leftover from the per-execution environment python interpreter removal.
- Modify parser to change the range of parenthesized expressions to their contents. This improves the ranges returned in hovers, document highlight, etc.
- Add boolean to ConfigOptions to check if the config was loaded from a config object (i.e., was produced in part by a `pyrightconfig.json` or `pyproject.toml` with a pyright section).

Co-authored-by: Bill Schnurr <bschnurr@microsoft.com>
2021-09-16 13:25:38 -07:00
Eric Traut
bd183acb03 Published 1.1.169 2021-09-15 22:07:51 -07:00
Eric Traut
fcfaa8b567 Fixed bug that caused false positive when a bound TypeVar is bound to an instantiable class (e.g. Type[X]). 2021-09-15 22:05:29 -07:00
Eric Traut
234d990d71 Added another optimization that limits number of recursive calls to getTypeFromFlowNode, a limit that is hit only in very complex untyped functions. 2021-09-15 20:57:56 -07:00
Eric Traut
809594e357 Added another perf optimization. Don't return an incomplete type when performing code flow analysis for purposes of determining reachability. 2021-09-15 20:38:15 -07:00
Eric Traut
86c729ab84 Fixed style issue 2021-09-15 16:25:44 -07:00
Eric Traut
a41cdc04c5 Added optimization that reduces the time it takes to perform code flow analysis in the presence of if/elf/else statements, try statements, with statements, and ternary expressions. 2021-09-15 15:13:44 -07:00
Eric Traut
f39520a220 Switched from Map to Set in code flow routine (minor cleanup). 2021-09-15 14:41:53 -07:00
Eric Traut
a53e8af9f9 Improved handling of attribute accesses for classes that inherit from Any or an unknown class. 2021-09-15 09:43:02 -07:00
Eric Traut
68a8c72ac4 Updated reportIncompatibleMethodOverride diagnostic check to special-case dict key names that overlap with method names in the _TypedDict class. 2021-09-14 19:12:15 -07:00
Eric Traut
a000f97c4d Improved type narrowing logic for a is b pattern where a is self (or a bound TypeVar) and b is an enum literal. 2021-09-13 22:04:13 -07:00
Eric Traut
b62daedccd Published 1.1.168 2021-09-13 21:41:44 -07:00
Eric Traut
b53d8a738a Updated typeshed to latest version 2021-09-13 21:40:48 -07:00
Eric Traut
097d36610e Fixed file naming capitalization issue. 2021-09-13 21:12:37 -07:00
Eric Traut
c680a8a7f3 Improved isinstance and issubclass support to handle the case where the type of the second argument is a union where the subtypes includes both tuples of class types and non-tuples. 2021-09-13 21:04:42 -07:00
Eric Traut
12a8c3b601 Fixed bug that resulted in incorrect type evaluation when co-dependent variables were assigned in a loop using tuple assignments (e.g. a, b = b, a + 1). 2021-09-13 20:41:26 -07:00
Eric Traut
9035f64c71 Added reportPrivateImportUsage diagnostic rule, which reports usage of a symbol from a py.typed library that is not intended to be re-exported by the library's author. The rule is on by default in basic type checking mode but can be disabled. Completion provider no longer offers these symbols as completion suggestions. 2021-09-12 01:10:57 -07:00