Commit Graph

6399 Commits

Author SHA1 Message Date
PylanceBot
932e542d9f
pull-pylance-with-pyright-1.1.319 (#5584) 2023-07-26 09:30:40 -07:00
Eric Traut
98a679202e Published 1.1.319 2023-07-25 20:01:48 -07:00
Eric Traut
1da8c18fcf
Added support for type narrowing of a class pattern when the specified class is type() or a subtype thereof and the subject contains a type[X] whose metaclass potentially matches the pattern. This addresses https://github.com/microsoft/pyright/issues/5573. (#5576)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-25 11:35:19 -07:00
Eric Traut
12e9c31187 Fixed a theoretical bug in the code that detects unique type signatures. It wasn't correctly handling constructor methods. 2023-07-25 11:03:46 -07:00
Eric Traut
e8250ba18f Fixed a bug that resulted in the incorrect inferred variance for a type variable used within a frozen dataclass. This addresses #5568. 2023-07-23 16:49:25 -07:00
Eric Traut
ff61d75fd6
Added support within the constraint solver for higher-order functions that accept a callable parameterized with a ParamSpec where the passed callable is generic. This addresses #5495. (#5567)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-23 11:14:17 -07:00
Eric Traut
deab6932df
Modified the heuristics used for narrowing on assignment when the assigned type contains an Any. If the target's declared type does not contain Any, the assignment shouldn't produce an Any within the resulting type. This addresses #5413. (#5566)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-23 08:49:06 -07:00
Eric Traut
c925ea5dde
Fixed a bug that led to a hang and eventual crash (due to memory exhaustion) under certain circumstances where a function returns a generic Callable whose type parameters are not used in the input parameters for the function. This addresses #5540. (#5565)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-22 16:28:10 -07:00
Eric Traut
914863edba
Updated typeshed stubs to the latest version. (#5563)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-22 09:05:48 -07:00
Eric Traut
a34eb58fc9 Added section on plugins to the comparison with mypy. 2023-07-22 08:25:37 -07:00
Eric Traut
a40ed76fa7 Simplified the bug and feature request templates and fixed a few typos in them. 2023-07-22 07:40:18 -07:00
Eric Traut
99dfe982a1 Added documentation about overloads and ParamSpec. 2023-07-22 07:23:43 -07:00
Eric Traut
b11e16cb3e
Fixed a bug that led to a false positive error when using bidirectional type inference for a dictionary expression when the expected type is a protocol. This addresses #5552. (#5562)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-21 21:39:02 -07:00
Eric Traut
2b420cf3a6
Removed fragile hack that was previously added to handle type var scoping for the synthesized constructor in a named tuple. (#5560)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-21 14:32:18 -07:00
Eric Traut
37f8149407 Fixed formatting of test case. No functional change. 2023-07-21 14:06:03 -07:00
Eric Traut
6e3404a1ce Improved comment for createCallableType. No functional change. 2023-07-21 13:35:27 -07:00
Eric Traut
5162e0fbd6 Enhanced support for functools.partial so it supports classes (constructors) when passed as the first argument. This addresses #5559. 2023-07-21 12:52:23 -07:00
Eric Traut
bf1ebd6794
Improved robustness of handling of circular dependencies for class evaluations. This addresses #5554. (#5558)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-21 10:53:52 -07:00
Eric Traut
39e355df24
Fixed a bug that led to a false positive when a constrained type variable was used as a type argument in an annotation for an argument passed to a method that's bound to the same type variable. This addresses #5556. (#5557)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-21 09:57:31 -07:00
Eric Traut
19194dd089
Fixed an inconsistency in reporting of unbound variables when the variable is captured by an inner scope. The new behavior correctly identifies unbound (or potentially unbound) variables in cases where the captured variable is narrowed. This happens when there are no assignments to the variable after it is captured. This addresses #5548. (#5551)
Fixed a bug in type narrowing for captured variables. Captured variables that are modified in other scopes using a `nonlocal` or `global` binding should be ineligible for type narrowing.

Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-20 21:08:53 -07:00
Eric Traut
a65b45ed45 Fixed a bug that resulted in a false positive error when bidirectional type inference was used with a class that defines a __new__ method within a generic class that returns an instance of the class whose type arguments do not match the type parameters. This addresses https://github.com/microsoft/pyright/issues/5404. 2023-07-20 15:25:05 -07:00
Eric Traut
c6e0f563f2
Added detection and reporting of illegal use of type[Callable] within a type annotation. This addresses https://github.com/microsoft/pyright/issues/5546. (#5549)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-20 12:00:10 -07:00
Eric Traut
97160a0350 Fixed bug in hover text where it was not producing the correct text output for an instantiable callable. 2023-07-20 10:30:17 -07:00
Eric Traut
9aa29e4e30
Fixed an issue in type evaluation of call expressions where the callable subexpression evaluates to a union, and the callable subtypes have different signatures. Pyright was previously caching the types from the first subtype, so it didn't re-evaluate using the second subtype (which may require bidirectional type inference). This addresses #5428. (#5547)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-20 09:54:08 -07:00
Eric Traut
98fcba13dd
Added support for the X is C and X is not C type guard pattern (where C is a class). This addresses #5490. (#5544)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-19 20:28:55 -07:00
Erik De Bonte
b917b7a5e0
Push pylance changes to pyright (#5542) 2023-07-19 12:46:11 -07:00
Eric Traut
455830ed42
Improved error messages for situations where a call expression targets an overloaded function or method and there are no matches. Added some heuristics to pick the "best" overload function for the error message. Previously, pyright used the last overload, but this sometimes led to confusing errors. This addresses #5525. (#5541)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-07-19 11:51:39 -07:00
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