Commit Graph

19 Commits

Author SHA1 Message Date
Eric Traut
8e1797cca7 Clarified in documentation that ... is an ellipsis token. 2024-06-11 14:18:55 -07:00
Eric Traut
98d1523077
Expanded support for len(x) == L type guard pattern (where x is a tuple) to support <, <=, > and >= comparisons as well. This addresses #7655. (#7657) 2024-04-09 23:13:17 -07:00
Eric Traut
bf4ddb357b Updated documentation for #7590. 2024-03-29 21:40:57 -06:00
Eric Traut
d58393b630 Updated documentation for "implied else". 2024-03-04 10:49:40 -07:00
Eric Traut
9e32b8fd57 Updated documentation to indicate support for PEP 742. 2024-02-19 01:17:00 -07:00
Eric Traut
a635a725a0 Updated documentation to refer to "value-constrained" TypeVars rather than just "constrained TypeVars", since all TypeVars are constrained in some manner. 2023-12-31 00:19:46 -07:00
Eric Traut
d3398850c4 Fixed documentation for class and instance variable overrides. 2023-11-28 13:21:16 -08:00
Eric Traut
012dc1c182
Extended the len(x) == L type guard logic to support arbitrary expressions L that evaluate to a literal int type. This addresses #6216. (#6219) 2023-10-21 12:09:19 -07:00
Eric Traut
db8fb3d60c Improved documentation for overload matching. 2023-10-16 13:19:38 -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
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
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
c767228a82 Improved documentation for "implied else" type narrowing. 2023-06-29 01:28:19 +02:00
Eric Traut
24b612fda2 Reverted overload change for now. It's causing breaks in the pandas-stubs library. More investigation is needed. 2023-06-06 17:53:24 -06:00
Eric Traut
746e03a49d Modified overload matching algorithm to better match that of mypy. In particular, if overload matching is ambiguous due to an Any or Unknown anywhere within an argument type (even within type arguments) and the resulting filtered overloads return the same generic type but with different type arguments, the resulting type was previously the return type of the first filtered overload. It is now the common generic type with erased type arguments. This addresses https://github.com/microsoft/pyright/issues/5216. 2023-06-03 17:36:09 -06:00
Eric Traut
39cac72d99 Improved documentation for conditional types. 2023-04-05 15:50:00 -07:00
Eric Traut
08085479ef Extended type narrowing for type guards of the form x[I] is B and x[I] is not B where x is a tuple and B is an enum literal. 2023-03-30 18:26:46 -07:00
Eric Traut
f1db88481f Added support for type guards of the form x[I] is B and x[I] is not B where x is a tuple and B is a boolean literal True or False. This addresses part of https://github.com/microsoft/pyright/issues/4875. 2023-03-30 18:10:06 -07:00
Eric Traut
c83a95e62e More improvements to documentation. 2023-03-07 16:38:22 -07:00