Commit Graph

3903 Commits

Author SHA1 Message Date
Eric Traut
312667173c Fixed a bug that led to a false negative when analyzing code with an async context manager that swallows exceptions. 2023-07-19 07:58:15 -07:00
Eric Traut
b953f79228 Fixed a bug that results in a crash when attempting to use a member access expression where the LHS is a TypeVarTuple. This addresses https://github.com/microsoft/pylance-release/issues/4630. 2023-07-19 07:03:50 -07:00
Eric Traut
1d558e07fc Published 1.1.318 2023-07-18 20:10:06 -07:00
Eric Traut
c34857f446 Fixed regression in recent (unpublished) change. 2023-07-18 20:09:45 -07:00
Eric Traut
ed295ddcaf Fixed bug that resulted in the incorrect variance inference of an "auto variance" type parameter (as introduced in PEP 695). 2023-07-18 19:51:12 -07:00
Eric Traut
5569939ee6
Fixed a bug that led to a false negative when determining type compatibility between two unions in an invariant context. This addresses #5534. (#5536)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-18 15:51:27 -07:00
dependabot[bot]
9855dc9c7f
Bump word-wrap from 1.2.3 to 1.2.4 (#5533)
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  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-18 14:05:03 -07:00
Eric Traut
d7b0a85f1d
Fixed a bug that resulted in a false positive when an expression of type type[Self] was used as the base type for a member access expression that was then used to call an instance method on that class. This addresses #5530. (#5532)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-18 13:20:17 -07:00
Eric Traut
5be5852603
Further refactored the internal implementation of validateCallArguments into subroutines so it is easier to maintain. Fixed a few small bugs that I discovered along the way. (#5529)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-18 10:22:25 -07:00
Eric Traut
dc81efff28
Fixed a bug that resulted in incorrect evaluation of a type alias defined with typing.TypeAlias and consisting of a single (naked) type variable. (#5527)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-18 07:37:34 -07:00
Eric Traut
7924640f95 Refactored logic to break up the validateCallArguments function in the type evaluator. It was getting very unwieldy. No functional change. 2023-07-17 14:55:49 -07:00
Eric Traut
6311bfb4f4 Fixed bug that caused an error to go undetected when the LHS of a call expression is a union that includes an abstract static or class method. 2023-07-17 13:59:36 -07:00
Eric Traut
77dd71ff10 Updated typeshed stubs to the latest version. 2023-07-17 08:06:16 -07:00
Eric Traut
6a25a7bf0b Removed the requirement that a TypedDict be marked @final for it to be considered for type narrowing as part of a S in D type guard pattern. This requirement wasn't sound because TypedDict is a structural type (i.e. a protocol), so @final doesn't have any real meaning. 2023-07-17 08:01:52 -07:00
Eric Traut
6169e0fb3c
Improved checks for illegal use of a variable within a type expression. Added enforcement of these same rules for the first argument to a cast call. This addresses https://github.com/microsoft/pyright/issues/5429. (#5520)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-16 23:59:10 -07:00
Eric Traut
8e8b6c31a2
Fixed recent regression that resulted in a false positive error when using bidirectional type inference for an assignment to a class-scoped variable where the annotated type is a descriptor. This addresses #5455. (#5519)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-16 22:25:47 -07:00
Eric Traut
7fcdc92320
Fixed a bug that resulted in a false negative when assigning a T | None type to object | None in an invariant context. This same bug led to issues with the validation of TypeVar variance within a Protocol. This addresses https://github.com/microsoft/pylance-release/issues/4613. (#5518)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-16 17:42:06 -07:00
Eric Traut
bfe2128ee9 Improved the error message for incompatible type arguments. Many users are confused about variance (in particular invariant type parameters). This change should help eliminate some of that confusion. This addresses #4583. 2023-07-16 15:18:12 -07:00
Eric Traut
88bff7e67f Added fsevents to lock file. 2023-07-15 17:03:23 -07:00
Adam Pauls
cc924295ae
Add fsevents as optional dependency to public package (#5503) 2023-07-15 17:01:00 -07:00
Eric Traut
2a096860c1 Reverted the change for #5446 because it's causing false positive errors. 2023-07-15 09:23:42 -07:00
Eric Traut
132e7edeab
Fixed bug that resulted in a false positive reportOverlappingOverload error when overload contained the use of a constrained TypeVar. This addresses #5511. (#5512)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-15 06:32:59 -07:00
Eric Traut
92f4e6bcf3
Modified is None type guard logic to eliminate Any or Unknown in the positive narrowing case. This addresses #5508. (#5509)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-15 05:16:51 -07:00
Eric Traut
01f40f0e98
Fixed bugs that resulted in incorrect or incomplete types when narrowing for sequence patterns in the negative case and the subject expression is a super-type of Sequence (such as object or Reversible). (#5507)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-14 19:12:58 -07:00
Eric Traut
bf158567f9 Eliminated the need to apply narrowing twice when evaluating the types of pattern targets in a match statement. This is a perf improvement but does not affect type evaluation. 2023-07-14 18:40:11 -07:00
PylanceBot
8e021d2ae8
[PylanceBot] Pull Pylance with Pyright 1.1.317 (#5505)
* pull-pylance-with-pyright-1.1.317

* Add missing types

---------

Co-authored-by: rchiodo <rchiodo@microsoft.com>
2023-07-14 14:26:45 -07:00
Rich Chiodo
b865a45061
Add capability for Pylance to override strings (#5497) 2023-07-14 10:17:10 -07:00
Eric Traut
6a15a6dc6d Minor code cleanup for consistency. 2023-07-14 09:11:14 -07:00
Vasista Vovveti
3efc3f2b71
Match CPython's __hash__ overriding behavior when __eq__ exists (#5501) 2023-07-14 09:06:32 -07:00
Eric Traut
844256cfb6 Added additional special-case handling for __init_subclass__ and __class_getitem__ to treat them as implicit class methods even if they are not declared using a def statement. This addresses #5500. 2023-07-14 01:25:54 -07:00
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