Commit Graph

6342 Commits

Author SHA1 Message Date
Eric Traut
6236155cb1
Fixed a bug in type narrowing for pattern matching in the negative (fall-through) case when the subject type contains an Any. This addresses #5492. (#5499)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-14 04:53:53 +00:00
Eric Traut
bb60966327
Fixed a recent regression that resulted in unsolved type arguments when a "bare" generic class (like dict) is passed as an argument to a function that accepts a type[T]. This addresses #5392. (#5494)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-13 15:39:33 +00:00
Eric Traut
1fa0a4f1cc
Added code to handle pathological case in unannotated code that writes to the same variable hundreds of times with different types. This mitigates the performance problem reported in #5475. (#5493)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-13 15:37:00 +00:00
Eric Traut
752b24aa3b Refactored "cast" call into its own function for readability. No functional change. 2023-07-13 12:30:03 +02:00
dependabot[bot]
75b33afaf8
Bump semver from 5.7.1 to 5.7.2 in /packages/vscode-pyright (#5484)
Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 23:21:38 +02:00
Eric Traut
2eee9558ae Published 1.1.317 2023-07-12 14:33:46 +02:00
Eric Traut
6ec6e74d63 Updated typeshed stubs to the latest version. 2023-07-12 10:36:33 +02:00
Eric Traut
e63f229d59 Added detection of errors when a namedtuple definition includes a language keyword. Also added minimal support for the rename parameter to the namedtuple function. This addresses #5423. (#5482)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 10:24:46 +02:00
Eric Traut
70ecdc2974
Improved protocol type cache for improved type analysis performance in code bases that make heavy use of protocols. (#5480)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 09:59:16 +02:00
Eric Traut
ada1ea63e8
Issue5405 5406 (#5470)
* Improved assignment mismatch errors to better handle the case where the two types have the same short name but different fully-qualified names. In this case, the types are now expanded to avoid confusion. This addresses #5406.

* Fixed incorrect type mismatch error messages within constraint solver logic. The source and destination types were swapped, which led to confusing messages. This addresses #5405.

---------

Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 00:27:35 +02:00
Eric Traut
8b38b5dbf9
Added support for deferred annotation evaluation for Annotated type arguments beyond the first one. This addresses https://github.com/microsoft/pylance-release/issues/4565. (#5472)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 00:24:14 +02:00
Eric Traut
f9796dd5cd
Fixed bug that led to a confusing hover type for the return result of an async generator function. This addresses #5411. (#5468)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 00:22:35 +02:00
Eric Traut
72491ca691
Modified diagnostic checks for list, dictionary, and tuple literal expressions within annotation expressions so they are emitted as part of the reportGeneralTypeIssue diagnostic rule rather than unconditionally. This addresses https://github.com/microsoft/pylance-release/issues/4587. (#5471)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 00:10:49 +02:00
Eric Traut
bc89399c9b
Fixed a bug that results in incorrect type evaluation for a higher-order function involving a ParamSpec. This addresses #5409. (#5469)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 00:09:23 +02:00
Eric Traut
9791786314
Removed limitation that files specified on the command line or in "include" directives end in ".py" or ".pyi". This addresses #5441. (#5463)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 00:06:03 +02:00
Eric Traut
af48e92690
Fixed recent regression in the synthesized TypedDict get method, which resulted in a false positive error when using strict mode. This addresses #5452. (#5462)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 00:04:54 +02:00
Eric Traut
c2094c0047
Fixed a bug that resulted in incorrect hover results for identifiers used as keys or values within a dictionary expression. This addresses #5422. (#5466)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 00:03:57 +02:00
Eric Traut
1c6cd1c06e
Extended support for TypedDict discrimination by literal field so it supports == and != with values that are unions of literal types. This addresses #5435. (#5464)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-12 00:00:08 +02:00
Eric Traut
e1063f112c
Issue5453 5454 (#5461)
* Fixed bug that resulted in false positive error when calling the same generic function with a ParamSpec multiple times as separate arguments within a call expression. This addresses #5453.

* Fixed another ParamSpec-related issue. This addresses #5454.

---------

Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-11 23:57:12 +02:00
Eric Traut
6bae2263e1
Added special-case support for enum fields that are assigned using an unpacked tuple operation. This addresses #5458. (#5460)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-11 23:54:51 +02:00
Eric Traut
c41bc9c055 Fixed regression where console output was emitted during tests, polluting the test output. 2023-07-08 12:44:05 +02:00
Eric Traut
0a67c65bef Clarified in documentation that no_type_check is not supported. 2023-06-30 08:39:10 +02:00
Eric Traut
c767228a82 Improved documentation for "implied else" type narrowing. 2023-06-29 01:28:19 +02:00
PylanceBot
74d8f3c4d2
pull-pylance-with-pyright-1.1.316 (#5401) 2023-06-28 10:35:29 -07:00
Eric Traut
4527c5baa3 Changed '-' command-line feature to support multi-line input. 2023-06-26 22:36:14 +02:00
Eric Traut
85c840c7a5 Fixed a regression that caused a false positive when comparing type compatibility between two Callable types that involve ParamSpecs. This addresses https://github.com/microsoft/pyright/issues/5384. 2023-06-26 22:27:25 +02:00
Eric Traut
67fe93239f Published 1.1.316 2023-06-26 09:02:52 +02:00
Eric Traut
ca370ef2b8
Fixed a bug that led to a false negative when a generic class with called its own constructor using its own type parameters as type arguments. This partially addresses https://github.com/microsoft/pyright/issues/5373. (#5381)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-25 19:41:40 +02:00
Eric Traut
d689dad11e
Moved the evaluation of the first iterator in a comprehension expression out of the comprehension scope to better reflect runtime behavior. (#5379)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-25 09:31:44 +02:00
Eric Traut
ec761d5909 Added isGenerator field to ListComprehensionNode. It's not currently used, but it will likely be useful in the future. 2023-06-25 09:16:02 +02:00
Eric Traut
c286eeca9c Cleaned up some generator test cases. 2023-06-25 08:09:48 +02:00
Eric Traut
9c01bf037b Added a small optimization to code path that assigns classes with type arguments. 2023-06-24 02:41:15 -07:00
Eric Traut
9444c01fb4 Fixed typo in comment. 2023-06-23 07:12:01 -07:00
Eric Traut
195b44e042 Moved decorator functionality out of type evaluator into its own module. 2023-06-22 22:38:22 -07:00
Eric Traut
367b603e42 Renamed a few internal functions for consistency. 2023-06-22 22:23:30 -07:00
Eric Traut
a74a503064
Fixed a bug that results in a false positive error when attempting to assign a class to a Callable type when the class is generic and the constructor includes class-scoped type variables in its parameter annotations. This addresses https://github.com/microsoft/pyright/issues/5369. (#5372)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-22 22:03:46 -07:00
Eric Traut
fbdfb52543 Removed some unnecessary code in the code path for comparing generic class types for type compatibility. 2023-06-22 21:17:36 -07:00
Eric Traut
1340dfac22 Added proper fix for regression that caused crash within certain doubly-nested loops. This addresses https://github.com/microsoft/pyright/issues/5355#issuecomment-1603646306. 2023-06-22 21:16:28 -07:00
Eric Traut
c8a25b2d61 Revert "Added mitigation for reported assertion failure (and crash). This temporarily addresses https://github.com/microsoft/pyright/issues/5355."
This reverts commit 7b242d5e5e.
2023-06-22 21:14:49 -07:00
Eric Traut
241cd62b95 Removed some unnecessary code in the code path that validates generic class type compatibility. 2023-06-22 21:01:49 -07:00
Eric Traut
ea96b47c68
Modified the signature of the synthesized get method for TypedDict classes so it more closely matches the signature (and therefore the behavior) of the get method in dict. This addresses https://github.com/microsoft/pyright/issues/5364. (#5365)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-21 20:44:28 -07:00
Eric Traut
7fb28a4371
Fixed a bug that resulted in a false positive when passing a class to the defaultdict constructor. If an unspecialized class type is used as a upper or lower constraint within the constraint solver, we now use default type arguments (typically Unknown) rather than leaving these type arguments unspecified. This addresses https://github.com/microsoft/pyright/issues/5354. (#5363)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-21 18:53:59 -07:00
Eric Traut
24e755025c Fixed formatting in test case. No functional change. 2023-06-21 16:02:39 -07:00
Eric Traut
b3c77ba45c
Fixed bug that resulted in incorrect type evaluation when a generic callback protocol was invoked in a nested manner. This addresses https://github.com/microsoft/pyright/issues/5356. (#5361)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-21 15:55:50 -07:00
Eric Traut
fb62cc9bf8
Added support for bidirectional type inference when using a dictionary expansion and a dictionary literal expression for an argument corresponding to an unpacked TypedDict **kwargs parameter. This addresses https://github.com/microsoft/pyright/issues/5358. (#5360)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-21 13:53:30 -07:00
PylanceBot
3f84540e0e
pull-pylance-with-pyright-1.1.315 (#5359) 2023-06-21 10:58:59 -07:00
Eric Traut
df7d83c171 Fixed another instance of a false positive reportMissingTypeArgument error when a generic class is passed as the second argument to isinstance. This addresses https://github.com/microsoft/pyright/issues/5294. 2023-06-21 09:52:40 -07:00
Eric Traut
7b242d5e5e Added mitigation for reported assertion failure (and crash). This temporarily addresses https://github.com/microsoft/pyright/issues/5355. 2023-06-21 08:09:40 -07:00
Eric Traut
d4fd3af6d3 Fixed a bug in the new - command-line feature. This addresses https://github.com/microsoft/pyright/issues/5342. 2023-06-20 19:15:24 -07:00
Eric Traut
cef2712bf3 Published 1.1.315 2023-06-20 18:34:15 -07:00