Commit Graph

4977 Commits

Author SHA1 Message Date
Eric Traut
977db37df2 Removed redundant check. 2022-05-10 21:31:14 -07:00
Eric Traut
29f1b15cb7 Removed unnecessary conditional check. No functional change. 2022-05-10 20:09:25 -07:00
Eric Traut
f5d931e05e Fixed a bug that resulted in a false positive reportUnknownVariableType diagnostic when using from .A import B statement. The symbol A was flagged as an "unknown" type even though it is not a symbol within the module's symbol table (unless the file is an __init__.py[i]). 2022-05-10 12:41:27 -07:00
Eric Traut
e860737771 Moved more functionality out of typeEvaluator.ts into constraintSolver.ts. No functional change. 2022-05-10 09:04:36 -07:00
Eric Traut
53198149dd Moved constraint solver from typeEvaluator.ts to its own file for maintainability. No functional change. 2022-05-10 08:55:43 -07:00
Eric Traut
07892e0da7 Added check for an attempt to overwrite a method that is marked @final. 2022-05-09 21:31:23 -07:00
Eric Traut
051f74cd68 Removed a bunch of unnecessary if statements and replaced them with ? operator. No functional change. 2022-05-09 21:05:02 -07:00
Eric Traut
8d5da97ba6 More doc improvements. 2022-05-08 11:12:37 -07:00
Eric Traut
9f08b64bcd Added documentation for class and instance variables. 2022-05-08 11:09:48 -07:00
Eric Traut
4c2c6bcc8f Updated "--stats" output in CLI to output both the number of files parsed & bound and the number of files checked. 2022-05-08 10:23:26 -07:00
Eric Traut
48688e94ac Added new verbose output for CLI when combined with '--stats' that outputs the total analysis time of each source file. This will help us narrow down performance problems. 2022-05-08 10:08:57 -07:00
Eric Traut
00dfbca947 Fixed a bug in the logic for synthesizing __init__ methods within a dataclass when a __slots__ definition is present. It was using the order of the slots entries rather than the order of the field declarations. 2022-05-07 17:01:56 -07:00
Eric Traut
cf016129df Fixed a bug in the reportUninitializedInstanceVariable check that results in a false positive error with TypedDict classes. 2022-05-07 16:27:22 -07:00
Eric Traut
ccc95e0545 Published 1.1.245 2022-05-07 01:08:40 -07:00
Eric Traut
b82a4f3266 Finished adding support for generic TypedDict classes. 2022-05-07 00:42:25 -07:00
Eric Traut
5932ef4efd Fixed performance issue that occurred in certain situations involving deeply nested loops and many unannotated variables that are dependent on each other. 2022-05-06 19:22:15 -07:00
Eric Traut
bd467644e5 Fixed a bug in the reportUninitializedInstanceVariable check that results in a false positive when used with a dataclass or dataclass-like class. Seemingly-uninitialized class variables are implicitly overwritten by the synthesized __init__ method in a dataclass. 2022-05-06 10:07:52 -07:00
Eric Traut
5bbb3b5eb8 Modified previous heuristic change so it applies only in cases where the source function has a declared return type with a literal annotation in it. It doesn't apply in cases involving an inferred return type or generic types that are specialized with literals. 2022-05-05 21:09:29 -07:00
Eric Traut
dd7e3b2b82 Changed the heuristics in the TypeVar constraint solver to preserve literals when solving for a TypeVar in a Callable return type. 2022-05-05 21:00:56 -07:00
Eric Traut
648ae44bfe Fixed bug that resulted in false positive error when using a member access expression within a list of base classes in a class declaration statement. 2022-05-05 16:15:49 -07:00
PylanceBot
28c431ef33
pull-pylance-with-pyright-1.1.244 (#3434)
Co-authored-by: HeeJae Chang <hechang@microsoft.com>
2022-05-05 13:44:57 -07:00
Eric Traut
5ed124e090 Fixed a bug that resulted in a stack overflow in rare cases where an unannotated decorator was used on hundreds of functions or methods within the same file. 2022-05-05 10:22:33 -07:00
Eric Traut
b9c187b9e8 Increased the stack trace limit for the CLI version of pyright from the default of 16 to 64 to help with diagnosis of crashes. 2022-05-05 10:20:43 -07:00
PylanceBot
4df1f74ba9
pull-pylance-with-pyright-1.1.244 (#3425)
Co-authored-by: Bill Schnurr <bschnurr@microsoft.com>
Co-authored-by: HeeJae Chang <hechang@microsoft.com>
Co-authored-by: Erik De Bonte <erikd@microsoft.com>
2022-05-04 10:17:49 -07:00
Eric Traut
80858f61dc Published 1.1.244 2022-05-03 23:51:43 -07:00
Eric Traut
74406b976d Added basic support for generic TypedDict classes, which are supported in Python 3.11. Assignment to a specialized generic TypedDict is now supported, but support for TypeVar solving is not yet in place. 2022-05-03 23:45:00 -07:00
Eric Traut
b8d6e23134 Improved error message for incompatible field types in a TypedDict. 2022-05-03 23:07:11 -07:00
Eric Traut
a9b6311ac5 Fixed bug that resulted in incorrect type evaluation of a dictionary key when assigning a dictionary expression to a dict with a generic key type. 2022-05-03 23:06:07 -07:00
Eric Traut
33d68d3e33 Fixed style issue. 2022-05-03 22:24:55 -07:00
Eric Traut
c1d29bfdb5 Added support for generic NamedTuple classes, which are now supported in Python 3.11. 2022-05-03 22:12:29 -07:00
Eric Traut
c4c27d6474 Fixed bug that resulted in incorrect type analysis for dataclasses when a field declaration was within a conditional block. 2022-05-03 20:48:05 -07:00
Eric Traut
8926b4b67e Changed heuristic for type matching when source is a concrete type and destination is a union of that type and a TypeVar. The old heuristic attempted to solve the TypeVar, but the new heuristic leaves it unsolved. This eliminates a false positive error in certain edge cases and more closely matches the behavior of mypy in this case. 2022-05-03 13:53:57 -07:00
Eric Traut
ee0f87220e Fixed a bug that resulted in a crash when overflowing the type cache. It is implemented with a Map, which has a limit of 2^24 entries. The fix is to empty the cache if we approach this limit. 2022-05-03 13:16:16 -07:00
Eric Traut
d51c430c4d Fixed bug that resulted in the incorrect inferred type for an exception group that results when using a Python 3.11 except* statement. 2022-05-02 20:44:41 -07:00
Eric Traut
1e3b455df2 Moved protocol logic out of typeEvaluator.ts and into its own module protocols.ts for maintainability. 2022-05-02 20:35:43 -07:00
Eric Traut
89fd2859c6 Enhanced the reportUninitializedInstanceVariable check to detect cases where a class variable is declared but not initialized in the class body and no instance variable of the same name is assigned in the __init__ method. 2022-05-02 18:51:52 -07:00
Eric Traut
1d756da35b Improved error message for a call expression that uses a named argument when the target callable has no such named parameter. 2022-05-02 18:34:43 -07:00
Eric Traut
5ec9e7deab Fixed bug that resulted in a false positive when a callback protocol used a method-scoped ParamSpec in its __call__ method. 2022-05-02 18:34:01 -07:00
Eric Traut
00b8d86805 Published 1.1.243 2022-05-01 19:38:11 -07:00
Eric Traut
3bce53eabf Fixed long-standing bug that resulted in incorrect code flow analysis and type evaluation when handling some forms of NoReturn calls. There are still some limitations though; for example, it doesn't handle overloaded functions that return NoReturn for some argument lists. 2022-05-01 19:15:22 -07:00
Eric Traut
ce1c56607b Made internal change to prepare for NoReturn changes. 2022-05-01 19:00:53 -07:00
Eric Traut
e504e174a2 Fixed bug that resulted in incorrect type evaluation when function return type inference resulted in various recursive cases. 2022-05-01 18:33:14 -07:00
Eric Traut
79f7688714 Fixed a recent regression that broke list and dictionary inference in cases where bidirectional type inference was used with an expected type that included a TypeVar that was bound to a literal type or a union of literals. 2022-05-01 17:53:06 -07:00
Eric Traut
642a29f34e More internal improvements to better understand source of assertions. 2022-05-01 10:13:24 -07:00
Eric Traut
15ce5c872b Removed the use of the deprecated string.substr call from tokenizer and replaced with string.substring. Added better logging to try to understand the source of an assert seen in pylance telemetry. 2022-05-01 10:11:11 -07:00
Eric Traut
790de09d53 Fixed a bug that resulted in a false positive error when performing protocol matching with a property whose getter included a custom type annotation for its self parameter. 2022-05-01 09:51:44 -07:00
Eric Traut
61d173ad43 Added check for illegal use of ClassVar within a TypeAlias declaration. 2022-05-01 09:30:50 -07:00
Eric Traut
e0cfc29bda Fixed a bug that resulted in false positive errors during protocol matching when a generic protocol derives from another generic protocol.
Fixed a long-standing bug in protocol matching where results were evaluation-order-dependent in cases where a generic source class included a method with an inferred return type that was dependent on one or more TypeVars. If the return type was not inferred and cached prior to protocol matching, it was improperly specialized.
2022-05-01 09:21:09 -07:00
Eric Traut
8f0d23ec5c Fixed a bug that resulted in incorrect import resolution in a library that you are debugging locally if that library is also installed in the current Python environment and the library includes stub (".pyi") files. 2022-04-30 15:17:46 -07:00
Eric Traut
11a43d66dd Fixed bug that resulted in incorrect type evaluation when referencing a descriptor object that is stored as an instance variable. 2022-04-30 11:40:46 -07:00