Commit Graph

5397 Commits

Author SHA1 Message Date
Eric Traut
ce8c57f44d
Did a cleanup pass on the code that accesses the param types. Some code paths were not using the appropriate accessor functions, so they were ignoring specialized param types and using the unspecialized (declared) type instead. (#8640) 2024-08-02 12:55:33 -06:00
Eric Traut
5ad9f1fea1 Fixed bug that results in a false positive reportUnsupportedDunderAll warning when using the __all__.extend(x.__all__) form and the list of entries in x is empty. This addresses #8636. 2024-08-02 08:10:19 -06:00
Eric Traut
7802376828 Changed disableLanguageServices feature to apply to hover text as well as other language services. Previously, hover text was excluded. This addresses #8639. 2024-08-02 07:59:47 -06:00
Eric Traut
842ab02c34
Fixed bug in the functools.partial logic that results in incorrect handling of an unpacked TypedDict when used with a **kwargs parameter. This addresses #8617. (#8630) 2024-07-31 23:12:50 -07:00
Eric Traut
33d2937b8c
Removed constraint solving logic from constraint tracker. All such logic should be contained within the constraint solver. (#8629) 2024-07-31 18:40:15 -07:00
Eric Traut
327dcfc42a
Removed a bunch of redundant and special-case handling of param specs that's no longer needed. (#8627) 2024-07-31 16:29:23 -07:00
Eric Traut
2eb14cba65
Separated constraint solving from the application of the solved type variables. (#8624) 2024-07-31 12:37:50 -07:00
Eric Traut
d300291291
Fixed bug that leads to internal data structure corruption and subsequent false positive errors in certain cases involving unions of Unknown types that include type aliases. This addresses #8608. (#8621) 2024-07-31 09:35:50 -07:00
Eric Traut
7ba1c62bdc
Fixed bug that results in a false positive error when a covariant type variable that is scoped to a method is used in a parameter annotation. This addresses #8614. (#8615) 2024-07-30 22:24:27 -07:00
Eric Traut
5992d8aae2 Published 1.1.374 2024-07-30 21:12:50 -07:00
Eric Traut
7532c0f5ca
Type var cleanup10 (#8613)
* Renamed TypeVarContext to ConstraintTracker in preparation for further refactoring. No functional change.

* Did some code cleanup in the constraint solver module.
2024-07-30 21:10:56 -07:00
Eric Traut
0b7d2ca240 Fixed regression that results in a false negative when an illegal type expression form is used within a PEP 695 constrained TypeVar definition. 2024-07-30 16:14:45 -07:00
Eric Traut
45161ef964
Fixed bug that results in a false positive when using a two-argument form of super() outside of a class. This addresses #8604. (#8611) 2024-07-30 15:59:57 -07:00
Eric Traut
28600608a6
Next round of simplification. Removed higherOrderTypeVarScopeIds. (#8610) 2024-07-30 15:10:45 -07:00
Eric Traut
e1d377efcd
Another round of cleanup and simplification. (#8609) 2024-07-30 14:36:51 -07:00
Eric Traut
3e936c7720
Further simplified code for tracking type vars. (#8606) 2024-07-30 12:44:20 -07:00
Eric Traut
8b5c1da2b5
Further simplified and cleaned up type var application code. (#8605) 2024-07-30 11:39:31 -07:00
Eric Traut
6913347aa8
Fixed bug that results in false positive error under certain circumstances when solving type variables that involve literal values. This addresses #8133 and #8048. (#8603) 2024-07-30 10:48:06 -07:00
Eric Traut
74345cc15f
Further simplified code in type var application code. (#8601) 2024-07-30 10:13:22 -07:00
Eric Traut
c9543bc987
Further simplification of the logic involved in type var solving. (#8600)
This addresses #8301 and #5855.
2024-07-30 10:00:00 -07:00
Eric Traut
b629011afc Added small optimization for argument type checking that saves some memory and time. 2024-07-30 00:48:40 -07:00
Eric Traut
a82a7b972c
Did more cleanup of the "apply solved type var" code path. (#8598) 2024-07-29 22:50:49 -07:00
Eric Traut
c82019fec5
Renamed "external" and "internal" type vars to "free" and "bound" respectively. This terminology is more reflective of their true meaning. No functional change. (#8595) 2024-07-29 21:33:50 -07:00
Eric Traut
85651bd849 Renamed "in-scope placeholder type variables" to "unification variables". No functional change. 2024-07-29 20:59:05 -07:00
Eric Traut
67f0b8d173
Simplified some of the logic involved in type var constraint solving. (#8594) 2024-07-29 20:50:55 -07:00
Eric Traut
4d2d197bff
Started to simplify some of the code involved in type var solving. (#8590)
Improved handling of type variable matching when a callee's parameter is a union of two or more "naked" type variables (like `S | T`).
2024-07-29 17:30:33 -07:00
Eric Traut
173ced142d
Fixed bug that can result in a false positive when calling the constructor within a class that has unannotated __init__ or __new__ method parameters. (#8582) 2024-07-29 11:03:28 -07:00
Eric Traut
e99b7726c8
Fixed bug that can result in a false negative when a function return type is a TypeVar and the function falls through and implicitly returns a None. (#8581) 2024-07-29 10:46:58 -07:00
Eric Traut
c2f5d26f03
Adjusted the heuristics for constraint solving to favor solutions of type T over type[T]` when both are valid. (#8579) 2024-07-28 22:26:34 -07:00
Eric Traut
cfd1a3710a Fixed bugs in a few test cases. 2024-07-28 13:19:58 -07:00
Eric Traut
f306d366dd
Modified heuristics in T is None type narrowing logic to handle TypeVars with no bounds better. The previous logic was arguably correct, but it produced results that were unexpected by some users. This addresses #8575. (#8578) 2024-07-28 10:36:47 -07:00
Eric Traut
d3d24d35bd
Added convenience accessor functions for TypeVars to test for constra… (#8576)
* Added convenience accessor functions for TypeVars to test for constraints, bounds, and Self. No functional change.

* Fixed style issue
2024-07-28 09:01:30 -07:00
Eric Traut
7e8dfb76ad Added support for @deprecated on __new__ methods used implicitly during a class constructor call. This addresses #8574. 2024-07-28 08:11:38 -07:00
Eric Traut
513d2ea697
Added support for @deprecated on __bool__ magic method used by not operator. (#8573) 2024-07-27 23:17:23 -07:00
Eric Traut
ed679c69d3
Added support for @deprecated decorator on magic methods for unary and binary operations. (#8572) 2024-07-27 22:42:20 -07:00
Eric Traut
5d68698462
Fixed bug that results in a false negative if a __set__ descriptor method is marked deprecated and is implicitly accessed using an augmented assignment operator, as in a.x += 1. (#8571) 2024-07-27 21:57:49 -07:00
Eric Traut
3931155adb
Fixed recent regression that can lead to a crash. (#8570) 2024-07-27 21:49:13 -07:00
Eric Traut
28b5427d55 Renamed some concepts in the typeVarContext and constraintSolver modules in preparation for a larger change. 2024-07-27 15:44:03 -07:00
Eric Traut
5397ee3470 Removed import cycle in typeVarContext module. 2024-07-27 14:58:53 -07:00
Eric Traut
bffbc33b69 Cleaned up data structures for TypeVarType to provide better type protection for ParamSpec and TypeVarTuple fields. Renamed TypeVarTuple test cases to conform better to internal terminology.
(cherry picked from commit 0a15f335ec5bba5f1b0997ffec4c622dad74bf13)
2024-07-27 14:52:58 -07:00
Eric Traut
01a82e2023 Renamed some internal symbol names for brevity (parameter => param). No functional change. 2024-07-27 12:03:36 -07:00
Eric Traut
a74871d46f Simplified cloneForSpecialization call to improve brevity and readability. 2024-07-27 11:21:49 -07:00
Eric Traut
8cab57e657 Renamed some internal symbol names for brevity (argument => arg). No functional change. 2024-07-27 11:02:57 -07:00
Eric Traut
31df557056 Removed some unused functionality from the TypeVarContext. 2024-07-27 10:39:52 -07:00
Eric Traut
4b91a0b222 Moved type complexity calculation into its own module. 2024-07-27 10:31:13 -07:00
Eric Traut
2c4032a920 Simplified TypeVarContext by removing some of the special-case handling for tupleTypeArgs. 2024-07-27 10:20:33 -07:00
Eric Traut
2bbd1bf288
Fixed a bug that can result in incorrect type evaluation when an isinstance type narrowing results in an intersection type. (#8564) 2024-07-27 10:17:05 -07:00
Eric Traut
7e7ad07453
Removed special-casing for None that is no longer needed. (#8562) 2024-07-26 21:04:49 -07:00
Eric Traut
c385edf274
Added missing check for Final variable assigned in a loop. (#8561) 2024-07-26 17:08:24 -07:00
Eric Traut
5f145eb010
Fixed a bug that results in incorrect type narrowing when tuples are used in conjunction with TypeIs. This addresses #8554. (#8559) 2024-07-26 16:14:37 -07:00
Eric Traut
87609b7f43 Refactored some functionality out of the type evaluator into a new tuples.ts module. 2024-07-26 14:00:16 -07:00
Eric Traut
93ce674190 Refactored code that creates pseudo-intersection types for isinstance type narrowing. No functional change. 2024-07-26 13:22:13 -07:00
Eric Traut
b076b783cb
Fixed a bug that results in an incorrect "inconsistent overload" error when the overloads return TypeIs or TypeGuard and the implementation returns bool. This addresses #8521. (#8556) 2024-07-26 11:53:40 -07:00
Eric Traut
a1f24db683
Fixed recent regression that results in a false positive error under certain circumstances when yield expression includes a call to a constructor. This addresses #8552. (#8553) 2024-07-26 09:49:37 -07:00
Eric Traut
28b452ac0f Simplified previous commit. 2024-07-25 20:34:19 -07:00
Eric Traut
5cea702a7e
Enhanced type narrowing for sequence patterns to support tuple expansion when the subject is a tuple whose entries are union types. This addresses #8516, #4995, #6437, and #7472. (#8547) 2024-07-25 20:21:13 -07:00
Eric Traut
06d28c39d5
Added a new configuration option enableReachabilityAnalysis. It is off by default when typeCheckingMode is "off" but otherwise on by default. When disabled, it causes pyright not to identify code blocks that are determined to be unreachable via type analysis. Code blocks that are determined to be unreachable via non-type information are still displayed as such. (#8546) 2024-07-25 19:13:15 -07:00
Eric Traut
5dd321a280
Fixed false positive error when iterator returns a class object from its __iter__ method. (#8545) 2024-07-25 17:48:03 -07:00
Eric Traut
4c3def9bbc
Added error check for an enum attribute with a "naked" Final attribute. This should be considered invalid. This addresses #8543. (#8544) 2024-07-25 17:00:53 -07:00
Eric Traut
95be64edeb
Updated code flow engine to distinguish between code that is unreachable based on type information and non-type information. (#8541) 2024-07-25 14:38:32 -07:00
Heejae Chang
ee42447964
push pylance to pyright 2024.8 (#8540)
* push pylance to pyright 3

* change config change back

* dont run some tests in real venv
2024-07-25 13:38:32 -07:00
Eric Traut
033ca1909b
Removed a bunch of redundant code related to annotation evaluation. (#8538) 2024-07-25 12:14:19 -07:00
Eric Traut
00ca6c38e8
Eliminated error condition when using a subscript expression for a generic class that does not conform to type expression rules (e.g. list[1 + 2]) if the expression is a value expression. This addresses #8534. (#8537) 2024-07-25 11:07:48 -07:00
Eric Traut
8f9f679a26
Changed evaluation behavior for TypeVar bounds, constraints, and defaults to enforce type expression evaluation rules, consistent with the typing spec. (#8536) 2024-07-25 10:41:30 -07:00
Eric Traut
6750ce5d74
Fixed recent regression that results in a false positive error when evaluating certain nested constructor calls when used with bidirectional type inference. This addresses #8519. (#8535) 2024-07-25 08:59:40 -07:00
Eric Traut
d20a0a2644
Fixed bug that results in a warning if the self parameter in an __init__ method is given an explicit Self annotation. This addresses #8532. (#8533) 2024-07-25 07:55:56 -07:00
Eric Traut
785d21962a
Fixed recent regression that results in incorrect isinstance type narrowing when the filter class and the type are both protocols. This addresses #8518. (#8529) 2024-07-24 17:06:52 -07:00
Eric Traut
d602f22098 Improved signature help for constructor calls. Replaced old heuristics that displayed either the __init__ or __new__ signature with a mechanism that uses the recently-ratified typing spec algorithm for converting a constructor into a callable. This is prompted in part by [this discussion](https://discuss.python.org/t/copying-signature-of-init-to-a-mixin-class-method/58907/2). 2024-07-24 16:10:48 -07:00
Eric Traut
385c84cce3 Fixed a bug that results in a crash in certain conditions involving a corrupt builtins.pyi stub. This addresses #8509. 2024-07-24 13:06:52 -07:00
Eric Traut
2cbd8752b4
Fixed bug in isinstance type narrowing if the second argument is object and the first argument is a type instance. This addresses #8520. (#8527) 2024-07-24 13:05:39 -07:00
Eric Traut
d833078226 Fixed bug that results in a crash if Optional is used with no subscript (i.e. Optional[]). This addresses #8524. 2024-07-24 12:24:00 -07:00
Eric Traut
21bfd0f5bb
Fixed bug in logic that validates subtyping relationships between TypeIs[T], TypeGuard[T] and bool when used in a return type of a callable. This addresses #8521. (#8523) 2024-07-24 10:26:58 -07:00
Eric Traut
258e2754bd Published 1.1.373 2024-07-23 17:06:24 -07:00
Eric Traut
77684ec7fc
Added support for auto-synthesized __replace__ method in dataclass … (#8514)
* Added support for auto-synthesized `__replace__` method in dataclass and namedtuple classes, a new feature in Python 3.13. This addresses #8300.

* Fixed broken test on Linux due to file system case sensitivity.
2024-07-22 22:31:18 -07:00
Eric Traut
39757e4519
Updated typeshed stubs to the latest version. (#8512) 2024-07-22 20:57:57 -07:00
Eric Traut
408b20b6c5
Eliminated a fragile assumption that Sequence and MutableSequence are nominal classes rather than protocols. This assumption holds today, but it might not in the future, and the pattern matching logic shouldn't rely on it. (#8510) 2024-07-22 20:15:53 -07:00
Eric Traut
ea8188fc77 Fixed bug that results in a crash if an explicit specialization of a class parameterized by a ParamSpec has zero type arguments. This is a syntax error, but it shouldn't cause the type evaluator to crash. 2024-07-22 12:23:36 -07:00
Eric Traut
616b2a5eea
Added support for bidirectional type inference for __extra_types__ in a closed TypedDict. This addresses #8503. (#8507) 2024-07-22 07:14:40 -07:00
Eric Traut
b9d25687f4
Fixed issues with the reportInconsistentConstructor. It produced false negatives in some cases and produced bad error messages in other cases. This addresses #8501 and #8500. (#8502) 2024-07-21 00:06:36 -07:00
Eric Traut
e812172ecf
Removed redundant assignment flag. (#8499) 2024-07-20 19:17:47 -07:00
Eric Traut
79959e7f6f Shortened some internal names for readability. No functional change. 2024-07-20 18:49:21 -07:00
Eric Traut
c2a1d6a99a Made support for "converter" parameter in dataclass_transform fields non-experimental. This functionality has been approved by the typing council. 2024-07-19 22:37:48 -07:00
Eric Traut
bf4c521c67 Added test case for #8494, which was already fixed by a previous commit. 2024-07-19 20:20:12 -07:00
Eric Traut
7434085425
Simplified check of the __init__ method by leveraging common code. (#8495) 2024-07-19 20:14:14 -07:00
Eric Traut
3f4235e965 Removed recently-added finally because it gets in the way of debugging. 2024-07-19 13:08:55 -07:00
Eric Traut
a508fad80e
Fixed a bug that can cause a hang during type analysis for complex code with loops. There are rare circumstances that can cause types not to converge due to symbol dependencies and unstable overload resolution. This change adds a hard limit on the number of attempts to converge types in a loop before giving up. It addresses #8279. (#8491) 2024-07-19 11:28:54 -07:00
Eric Traut
3b5aba31df
Fixed bug that resulted in an infinite loop when evaluating a call that passes the same call as an argument. Simplified tracking of unique signatures within the code. This addresses #8047. (#8488) 2024-07-18 23:10:02 -07:00
Eric Traut
0eeffb0ab2
Improved type evaluation for tuples index expressions with negative subscripts and an entry with an indeterminate length. This addresses #8485. (#8486) 2024-07-18 19:22:37 -07:00
Eric Traut
7554fea844
Fixed bug that results in a false positive "overlapping overload" diagnostic when the later overload includes a callback function with a TypeVar in a parameter type. This addresses #8465. (#8484) 2024-07-18 19:18:28 -07:00
Eric Traut
405e6288cb
Fixed a bug that results in incorrect type narrowing when using TypeIs form when the return type of the type guard function is a specialized generic class. This addresses #8460. (#8483) 2024-07-18 16:35:10 -07:00
Eric Traut
55f1f5f6a8
Added the distinction between "external" versus "internal" type variable scopes. This is important for generic class implementations that call their own constructors. (#8482)
This is a significant change with high potential for regressions.

It addresses #8165, #7988, #7507, #7369.
2024-07-18 14:33:02 -07:00
Eric Traut
90b1bfbd34
Added check for class attribute type declarations that use method-bound type variables. These should be illegal. This addresses #8479. (#8480) 2024-07-18 12:17:45 -07:00
Eric Traut
20d985f007
Changed internal behavior to retain type alias information when applying solved type variables for a type. (#8476) 2024-07-18 09:38:50 -07:00
Eric Traut
f4ac69bf05
Added some additional improvements and tests from another working branch. (#8474) 2024-07-18 08:40:34 -07:00
Eric Traut
c6a449d1a1
Added a small optimization for the previous change to bidirectional inference for call expressions. (#8472) 2024-07-18 08:17:34 -07:00
Eric Traut
42c379bbb8 Added provisional support for draft PEP 736 (keyword argument shortcut syntax). This addresses #8470. 2024-07-18 01:13:42 -07:00
Eric Traut
1d9b8b5ece
Fixed a bug that results in a false positive error when using bidirectional type inference for a call expression where the expected type is a union. This addresses #8449 and #8463. (#8468) 2024-07-17 20:27:16 -07:00
Eric Traut
c116e6af19
Fixed a bug that results in incorrect type evaluation in certain edge cases involving bidirectional type inference with TypeVarTuples. (#8461) 2024-07-17 16:37:23 -07:00
Eric Traut
25cfdf7fcf
Changed all diagnostic generated in the type evaluator to have a diagnostic rule associated with them so their severity is under user control. This addresses #8453. (#8456) 2024-07-17 12:10:33 -07:00
Eric Traut
60c3b168a7
Fixed regression that results in a false positive when an Annotated type is used in a type argument within a specialized type on the LHS of a call expression, such as list[Annotated[int, ""]](). This addresses #8454. (#8455) 2024-07-17 11:57:56 -07:00
Eric Traut
d6372d4570 Published 1.1.372 2024-07-16 18:39:04 -07:00
Eric Traut
f5edd2b85d
Added some changes from another branch. (#8445)
Added some changes from another branch.
2024-07-16 12:50:25 -07:00
Eric Traut
5d6b96bc60
Incorporated several bug fixes and cleanups from an alternate branch. (#8443) 2024-07-16 11:13:20 -07:00
Eric Traut
e78b3b87f7
Refactored the code for TypeVar scope ID assignment to improve readability and maintenance. (#8440) 2024-07-15 16:47:10 -07:00
Eric Traut
baf6572b41
Fixed false positive error when using an overloaded __init_subclass__ method under certain circumstances. This addresses #8436. (#8439) 2024-07-15 15:08:26 -07:00
Eric Traut
b470f3e4d2
Changed logic for explicit specialization to allow Never as a type argument for a value-constrained type parameter if Never is an explicit constraint. This addresses #8432. (#8438) 2024-07-15 13:05:07 -07:00
Eric Traut
86869f0c94
Added "literal math" support for exponentiation operator. This addres… (#8437)
* Added "literal math" support for exponentiation operator. This addresses #8434.

* Refactored binary ops "literal math" code for maintainability and readability.
2024-07-15 12:49:45 -07:00
Eric Traut
042d2ea582
Fixed bug that results in some circumstances in incorrect specialization of type[T] when T evaluates to Any. This addresses #8429. (#8431) 2024-07-14 23:40:44 -07:00
Eric Traut
6990c98c12
Further simplified bidirectional inference logic for calls. (#8427) 2024-07-14 14:37:31 -07:00
Eric Traut
3bf626b020
Improved and simplified then handling constructor calls for classes t… (#8426)
* Improved and simplified then handling constructor calls for classes that have no `__init__` or `__new__` method.

* Removed unused localized string.
2024-07-14 11:34:56 -07:00
Eric Traut
89341d308d
Improved the handling of bidirectional type inference for call expressions when the expected type comprises a union. (#8425) 2024-07-14 11:07:16 -07:00
Eric Traut
b88e3dcef2
Incorporated some code cleanup changes from another working branch. (#8424) 2024-07-14 10:46:07 -07:00
Eric Traut
426fe55611
Fixed bug that results in a false positive error under certain circumstances when a generator function with no type annotation contains a return value. This addresses #8421. (#8422) 2024-07-14 09:01:52 -07:00
Eric Traut
9daf584ba4
Added "literal math" support for bitwise operators (left shift, right shift, logical or, logical and, logical xor, and invert). This addresses #8419. (#8420) 2024-07-13 23:09:16 -07:00
Eric Traut
f72be7b6b4 Added optimization to monomorphize objects used in the code flow engine. 2024-07-13 20:59:39 -07:00
Eric Traut
1e218a2cfe
Fixed inconsistent behavior when evaluating a binary expression with an or or and operator when the LHS evaluates to a literal int, str, bytes or bool type. This addresses #8417. (#8418) 2024-07-13 20:09:56 -07:00
Eric Traut
5192889fb5 Renamed fields in parse nodes to reduce verbosity and increase consistency. 2024-07-13 17:48:02 -07:00
Eric Traut
210bb144d7
Modified parser data structures to make parse nodes monomorphic and improve performance. (#8416) 2024-07-13 17:45:13 -07:00
Eric Traut
5ac7f49a3f Eliminated maxChildDepth field from parse nodes. 2024-07-13 15:55:32 -07:00
Eric Traut
496822d3d0
Modified typing data structures to increase monomorphism for performance reasons. (#8415) 2024-07-13 14:43:45 -07:00
Eric Traut
17bd81a7de
Next step in attempting to make typing types monomorphic. (#8413) 2024-07-13 12:35:34 -07:00
Eric Traut
d2d0fdcd23
Did a small refactor of the FunctionType interface and eliminated a field. (#8412) 2024-07-13 10:50:07 -07:00
Eric Traut
2f1bce7b25
Fixed a bug that results in incorrect import resolution behaviors when a ".py" file and a directory have the same name, and the directory doesn't have a __init__.py file in it. In this case, the ".py" file should take precedence during imports. This addresses #8408. (#8410) 2024-07-13 09:50:07 -07:00
Eric Traut
897081901e
Did some refactoring and code cleanup in import resolver in preparation for a bug fix. (#8409) 2024-07-13 09:27:41 -07:00
Eric Traut
47ea13bc2d
Changed the type of the __doc__ attribute for a module to always be str | None. Previously, pyright changed its declared type to str if a docstring was present in the module, but this is incorrect because it's a writable value and can be set to None. This addresses #8388. (#8397) 2024-07-12 10:58:20 -07:00
Eric Traut
96ee9c6268
Changed union creation logic to retain (rather than elide) redundant literals in some cases. In particular, for type expressions that explicitly include literals along with their non-literal counterpart like Literal[1] | int. Retaining these redundant subtypes can be useful for language server features like completion suggestions. This addresses #8392. (#8396) 2024-07-12 09:52:22 -07:00
Eric Traut
30e139b5f8
Fixed a bug that results in a false positive reportOverlappingOverload error in certain cases involving ParamSpec and Concatenate. This addresses #8389. (#8393) 2024-07-12 08:51:34 -07:00
Eric Traut
71928e1b00
Changed the way FunctionParam objects are created so they are monomorphic. (#8387) 2024-07-12 00:02:29 -07:00
Eric Traut
2f88f837d0
Did some code cleanup in the types module. Eliminated a few unnecessary optional fields in common objects. (#8386) 2024-07-11 21:51:36 -07:00
Eric Traut
a740945cd7 Removed the builtinName field from FunctionType. It can be represented by a flag more economically. 2024-07-11 20:49:26 -07:00
Eric Traut
2dffecb0f2
Added support for class declarations within an enum class body -- both with and without @member and @nonmember decorators. This addresses #8366. (#8385) 2024-07-11 20:31:19 -07:00
Eric Traut
827684ac2e
Fixed a bug that results in false positive reportInconsistentConstructor errors if one or both of __init__ or __new__ are overloaded. This addresses #8372. (#8383) 2024-07-11 19:27:25 -07:00
Eric Traut
39d76a86e7
Fixed a recent regression that results in a false positive when the fully-qualified form of typing.Request is used in an annotation expression. This addresses #8375. (#8381) 2024-07-11 17:36:23 -07:00
Eric Traut
472d86519d Improved consistency of parse node interface definitions. No functional change. 2024-07-11 16:56:22 -07:00
Rich Chiodo
d06b5999ca
Current working directory can't override OS so not necessary to remove it (#8364) 2024-07-10 10:49:42 -07:00
Eric Traut
109a9d03f8
Fixed bug in type narrowing logic for sequence pattern matching when a "star" entry in the pattern captures a TypeVarTuple. The resulting type should be Unknown rather than the unpacked TypeVarTuple. (#8365)
Fixed bug that results in a false positive when assigning type `tuple[Any, ...]` to `tuple[*TS]`. This should be allowed because `tuple[Any, ...]` is a gradual form that is assignable to all tuple types.

This addresses #8357.
2024-07-10 10:24:01 -07:00
Eric Traut
dded9fb056
Added support for negative type narrowing (in the fall-through case) for a mapping pattern consisting of a single dictionary expand entry. This should match all mapping types, eliminating them in the fall-through case. This addresses #8356. (#8363) 2024-07-10 09:27:47 -07:00
Eric Traut
4c4767ef81
Fixed bug that can result in incorrect evaluation of a traditional (pre-PEP 695) type alias the defines a union which is later used as the second argument to an isinstance or issubclass call. This addresses #8358. (#8362) 2024-07-10 08:19:14 -07:00
Eric Traut
8f82d8d3f6 Published 1.1.371 2024-07-09 15:29:04 -07:00
Rich Chiodo
d1b4d65616
Make python interpreter execution more secure (#8341)
* Make python interpreter execution more secure

* Fix test failure
2024-07-09 09:51:07 -07:00
Eric Traut
84b00a627d Updated lock file. 2024-07-08 23:02:54 -07:00
Eric Traut
9c16cc3e49 Bumped min engine version from 1.86 to 1.89 to match the recently-updated language client library requirements. This addresses #8344. 2024-07-08 23:01:35 -07:00
Eric Traut
1925023629 Fixed bug that causes a false positive error when an __init_subclass__ has overloads. This addresses #8343. 2024-07-08 22:59:40 -07:00
Eric Traut
f6dd5c5bef Updated typeshed stubs to the latest version. 2024-07-08 19:36:37 -07:00
Eric Traut
d785aac750
Fixed type evaluation of old-style (pre-PEP 695) type alias that aliases a generic class when it is used as a direct constructor call. This addresses #8337. (#8338) 2024-07-08 13:56:38 -07:00
Eric Traut
fd6081f12d
Did some general code cleanup in type evaluator including shortening names of some variables and functions for readability. (#8330) 2024-07-07 16:08:22 -07:00
Eric Traut
ab6fe409a6 Code cleanup for selfSpecializeClass. 2024-07-07 12:29:52 -07:00
Eric Traut
5332daa9cb Small code cleanup in validateCallForFunction. 2024-07-07 11:59:28 -07:00
Eric Traut
04490f2645 Reformatted test samples using ruff. 2024-07-07 10:34:25 -07:00
Eric Traut
7d410cfbee
Improved handling of tuple expressions used in type expressions that involve specialization, such as dict[()]. (#8329) 2024-07-07 10:06:08 -07:00
Eric Traut
f8bbf78ca5
Added code to TypeVar transform to update the boundToType and strippedFirstParamType. (#8328) 2024-07-07 09:55:03 -07:00
Eric Traut
4c001a139c
Improved type narrowing in the fall-through case for sequence patterns when the pattern includes a star pattern and the subject type is a tuple with an indeterminate entry. (#8323) 2024-07-06 14:44:46 -07:00
Eric Traut
228bd84c54 Fixed bug that results in false negative when a list or set expression includes more than 64 elements and is being evaluated with a bidirectional inference context. This addresses #8314. 2024-07-06 11:51:09 -07:00
Eric Traut
1c85d650ae
Fixed bug that results in a false positive error when using a TypeVar with an upper bound of type as a base class in a class statement. This addresses #8313. (#8321) 2024-07-06 11:47:37 -07:00
Eric Traut
3ddf0ad705
Improved detection of the use of variables used in type annotations. These are illegal according to the typing spec. (#8318)
This addresses #8316.
2024-07-06 10:18:21 -07:00
Eric Traut
598119b90f Fixed bug that results in a false positive error when an unpack operator is used in an unparenthesized tuple expression on the RHS of an augmented assignment operator on Python 3.9 and newer. This addresses #8310. 2024-07-05 09:27:25 -07:00
Eric Traut
8a23d8f596 Fixed bug that results in --outputjson command-line option being incompatible with --threads command-line option. 2024-07-05 09:10:49 -07:00
Eric Traut
057b351efa
Added support for multithreaded type checking in CLI. (#8309) 2024-07-04 20:52:37 -07:00
Eric Traut
746749272c Exposed maxSourceFileSize from sourceFile module. 2024-07-04 17:54:51 -07:00
Eric Traut
4fd12df54a Added functions for converting diagnostics to/from a form that is compatible with JSON serialization. 2024-07-04 17:54:15 -07:00
Eric Traut
4df7ba72a0 Revert "Improved the internal name given to a class that is created through the explicit instantiation of a metaclass."
This reverts commit 8792e4e493.
2024-07-03 14:48:48 -07:00
Eric Traut
8792e4e493 Improved the internal name given to a class that is created through the explicit instantiation of a metaclass. 2024-07-03 14:47:04 -07:00
Eric Traut
8ed6c10486
Changed the hard-coded type of the __class__ symbol to be Self@T rather than T (where T is the enclosing class). This addresses #8305. (#8307) 2024-07-03 14:45:58 -07:00
Eric Traut
d7c5d0691a
Fixed regression that results in a false positive when a traditional type alias (not using PEP 695 syntax) defines a union and is then used as a second argument to an isinstance or issubclass call. This addresses #8302. (#8303) 2024-07-03 12:27:02 -07:00
Eric Traut
93ac52f0b2 Published 1.1.370 2024-07-02 16:45:35 -07:00
Eric Traut
0591abaae8 Fixed bug that results in a false positive reportUntypedFunctionDecorator error under certain circumstances. This addresses #8298. 2024-07-02 16:40:34 -07:00
Eric Traut
8a766d59a4
Fixed bug that results in a false negative when passing an extra keyword argument to a callable that is parameterized with a ParamSpec. This addresses #8294. (#8299) 2024-07-02 16:35:08 -07:00
Eric Traut
280ed52e8c Shortened names of EvalFlags to improve readability. No functional change. 2024-07-02 13:38:58 -07:00
Eric Traut
33a72e3d6a
Improved handling of special forms, including TypeAliasType instances, when used in value expressions. This addresses #8185. (#8296) 2024-07-02 13:30:36 -07:00
Eric Traut
f6c9ca9feb Renamed evaluation flag for clarify and consistency. No functional change. 2024-07-02 08:47:10 -07:00
Eric Traut
2947be68bf Did more code cleanup in the assignment statement evaluation code path. 2024-07-01 20:50:20 -07:00
Eric Traut
3da465b321 Reduced duplicated code in type alias code paths. No functional change. 2024-07-01 20:28:01 -07:00
Eric Traut
139d095cd6
Implemented small optimization in the protocol matching cache. (#8288) 2024-07-01 10:47:36 -07:00
Eric Traut
21efa0ecf8 Fixed bug that results in the incorrect default value of a variadic type variable when the type argument is not provided. It should default to *tuple[Any, ...], not *tuple[Any]. This addresses #8285. 2024-07-01 08:13:44 -07:00
Eric Traut
74846de568
Improved performance of type analysis by caching additional reachability information for code flow graphs. This addresses #8275. (#8281) 2024-06-30 21:13:47 -07:00
Eric Traut
8a9ba9b77b Fixed bug that resulted in a false positive error when an abstract class is used for a NewType and the new type is constructed. This addresses #8256. 2024-06-30 19:48:08 -07:00
Eric Traut
353a17cdec
Improved analysis performance for complex code flow graphs by adding a cache for reachability. This addresses #8276. (#8278) 2024-06-30 17:17:38 -07:00
Eric Traut
4980567942
Reformatted Python test samples using the latest version of ruff. (#8277) 2024-06-30 17:07:20 -07:00
Eric Traut
3e70e7a8f9 Renamed internal function for clarity. No functional change. 2024-06-30 05:49:24 -07:00
Eric Traut
d55be983e5 Fixed a bug in the type narrowing for the "x is <class>" type guard pattern when <class> is a specific class T, as opposed to a variable of type type[T]. This addresses #8264. 2024-06-29 11:05:51 -07:00
Eric Traut
fa0f6b7349 Small code cleanup. No functional change. 2024-06-29 11:05:09 -07:00
PylanceBot
16f398976a
pull-pylance-with-pyright-1.1.369-9716881771 (#8261)
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rich Chiodo <rchiodo@users.noreply.github.com>
2024-06-28 17:41:06 -07:00
Eric Traut
bee1d912fd Fixed bug that results in a spurious error when evaluating a quoted (forward reference) type expression that includes an index expression within a TypeAlias definition. This addresses https://github.com/microsoft/pylance-release/issues/6072. 2024-06-28 15:15:20 -07:00
Eric Traut
3c70b4e0d1
Fixed bug that results in incorrect type evaluation of a function that accepts a Callable[P, T] and is passed a class object whose constructor needs to be converted to a callable. This addresses #8170. (#8258) 2024-06-28 10:19:57 -07:00
Kacie Kang
5d5fe5d15c
fix pylance issue 6052 (#8253) 2024-06-27 16:22:49 -07:00
Eric Traut
8f8f5b163d
Fixed recent regression that results in false positive when a inner function with an inferred return type is a coroutine (async) and is referenced within the function body in which it's declared. This addresses #8232 and #8229. (#8251) 2024-06-27 13:16:23 -07:00
Eric Traut
f104e7bb30
Fixed bug that results in false positive reportInconsistentOverload and reportNoOverloadImplementation errors when an overloaded decorator is applied to a non-overloaded function or method. This addresses #8246. (#8249) 2024-06-27 05:35:50 -07:00
Eric Traut
1e1e912380 Fixed bug that results in a false positive when a protocol includes a method implementation that conditionally raises NotImplementedError. This addresses #8245. 2024-06-27 04:30:13 -07:00
Eric Traut
337ef2fa00 Fixed recent regression that results in an assertion failure (and therefore a crash) when type() is called with dynamic base classes. This addresses #8228. 2024-06-26 16:51:15 -07:00
Eric Traut
bdb8eba712 Updated typeshed stubs to the latest version. 2024-06-26 16:30:53 -07:00
Eric Traut
05726120ad
Fixed bug that results in incorrect type isinstance or issubclass type narrowing when using a type variable with an upper bound that includes a promotion type. This addresses #8238. (#8243) 2024-06-26 16:30:26 -07:00
Eric Traut
427ca1143e Fixed bug that resulted in a false negative when assigning to type tuple[Never]. This addresses #8237. 2024-06-26 15:01:45 -07:00
PylanceBot
1168be715e
pull-pylance-with-pyright-1.1.369-9665934702 (#8225)
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-06-25 10:09:34 -07:00
Eric Traut
a5cbd4725a Published 1.1.369 2024-06-25 18:02:18 +02:00
Eric Traut
24f64f7d26 Fixed bug that results in incorrect type narrowing in the negative (fall-through) case of a match expression when the subject expression is an unbounded tuple. This addresses #8219. 2024-06-25 13:56:02 +02:00
Eric Traut
2672441c22 Fixed bug that leads to a spurious "unbound variable" diagnostic when a variable is assigned a value using a walrus operator and is later used in a ** call argument. This addresses #8218. 2024-06-25 13:28:04 +02:00
Eric Traut
bc1fc9f22b Added support for walrus (assignment) operator within set literal expressions if the python version is >= 3.10. The grammar was changed in 3.10 to support this. This addresses #8216. 2024-06-24 23:56:08 +02:00
Eric Traut
3a263135ab
Fixed bug that incorrectly evaluates a constructor call to a constructor that infers a class-scoped ParamSpec when the passed function is generic. This addresses #8170. (#8215) 2024-06-24 22:04:09 +02:00
Eric Traut
6ffb60bd53
Fixed bug that results in a false positive error when using a callback protocol with a function-scoped type variable. This addresses #8177. (#8207) 2024-06-23 14:57:32 +02:00
Eric Traut
ee12ebcccf Improved reportUninitializedInstanceVariable check to handle dataclass variables that are initialized implicitly by the synthesized __init__ method. 2024-06-22 21:44:36 +02:00
Erik De Bonte
3e6661a315
Fix binary search in findNodeByOffset to match linear search result (#8143) 2024-06-22 09:10:06 -07:00
dependabot[bot]
cfeed20baf
Bump braces from 3.0.2 to 3.0.3 (#8204)
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-22 15:24:27 +02:00
Eric Traut
2efc12f999
Improved diagnostic messages for type errors detected during __set__ and __delete__ calls to a descriptor object. This addresses #8181. (#8198) 2024-06-21 23:13:01 +02:00
Eric Traut
d2ff2a4517
Fixed bug that results in an incorrect overload implementation diagnostic when using tuple[()] in overloads. This addresses #8194. (#8195) 2024-06-21 13:25:01 +02:00
Eric Traut
221a977705 Changed hover provider output for type aliases to conform more closely with the new Python 3.12 type syntax. This partially addresses #8185. 2024-06-21 12:41:22 +02:00
Eric Traut
1bbb5d90a1 Fixed recent regression that results in a runtime assert (and therefore a crash) in certain circumstances when computing the MRO for a class. This addresses #8191. 2024-06-20 21:33:48 +02:00
Eric Traut
b841e110f3
Improved consistency of unreachable code. Previously, unreachable code was not supported for if or else suites when the condition type was narrowed to Never. This addresses https://github.com/microsoft/pylance-release/issues/6028. (#8190) 2024-06-20 17:00:26 +02:00
Eric Traut
81ff21e21a
Fixed bug that leads to a false negative when a subscript object used in an index expression supports __index__ but the indexed object specifies that it requires int. This addresses #8183. (#8188) 2024-06-20 16:14:49 +02:00
Eric Traut
98d68d5d3a Fixed recent regression in reportUninitializedInstanceVariable check relating to NamedTuple instance variables. This addresses #8184. 2024-06-20 14:44:57 +02:00
PylanceBot
b7be7b9a10
pull-pylance-with-pyright-1.1.368-9572872079 (#8173)
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rich Chiodo <rchiodo@users.noreply.github.com>
2024-06-19 11:00:21 -07:00
Eric Traut
20942b3389
Added support for detecting mismatched property types in base classes used for multiple inheritance. This addresses #8167. (#8175) 2024-06-19 08:52:40 +02:00
Eric Traut
1bf99d3212 Published 1.1.368 2024-06-19 00:01:32 +02:00
Eric Traut
86715ec758 Fixed bug that results in unions consisting of different specialized forms of a generic TypedDict to "lose" all but one of these subtypes. This addresses #8169. 2024-06-18 23:31:13 +02:00
Eric Traut
918bc4c745 Removed some vestigial code related to inlined TypedDicts. 2024-06-18 23:17:37 +02:00
dependabot[bot]
e54e2f4399
Bump braces from 3.0.2 to 3.0.3 in /packages/pyright-internal (#8172)
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-18 22:51:29 +02:00
dependabot[bot]
beb1f15f4b
Bump braces from 3.0.2 to 3.0.3 in /packages/pyright (#8122)
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eric Traut <eric@traut.com>
2024-06-18 22:48:31 +02:00
Eric Traut
18511f1441 Added check for illegal use of Protocol type argument that is not a type parameter. The runtime generates an exception for this condition. This addresses #8158. 2024-06-17 23:05:57 +02:00
Eric Traut
ef025a1ac2
Fixed bug in pattern matching for Callable() in the negative (fall-through) case. This addresses #8160. (#8163) 2024-06-17 23:04:30 +02:00
InSync
0f654e077b
Fix stubPath's default value in schema (#8156) 2024-06-17 14:25:17 +02:00
Eric Traut
48a03076a3 Fixed bug that resulted in the incorrect synthesis of __dataclass_fields__ for named tuples. This addresses #8152. 2024-06-16 22:41:09 +02:00
Eric Traut
7ca7631808 Changed the way that PEP 695 type aliases are displayed when hovering over a reference to the type alias. Previously, the symbol was displayed as TypeAliasType rather than the expanded type alias type. This addresses #8147. 2024-06-15 19:03:12 +02:00
Eric Traut
6dc3b39902 Fixed a bug in the "type printer" (the component responsible for translating a type into its textual form) for type aliases defined using PEP 695 syntax. 2024-06-15 18:28:09 +02:00
Eric Traut
a03eb8492e Removed recent change in dataclass_transform handling. Dataclass properties should not be inherited from base classes after all. See https://discuss.python.org/t/dataclass-transform-inheriting-class-doesnt-recognize-kw-only-true-from-parent-class/55734/2. 2024-06-14 09:15:34 -07:00
Eric Traut
cbd189a29f
Changed dataclass_transform behavior to allow dataclass behaviors (like kw_only) to be overridden by intermediate base classes. This addresses #8140. (#8141) 2024-06-13 15:29:01 -07:00
Eric Traut
75d0f2b5a1 Fixed regression that results in an internal assertion (and crash) related to TypeVar variance inference. This addresses #8137. 2024-06-13 09:42:37 -07:00
Eric Traut
093e74aa6e
Fixed bug that causes a "bare" type (with no type argument) or type[Any] to be treated as a possible descriptor object. This addresses #8136. (#8138) 2024-06-13 08:56:09 -07:00
Eric Traut
5cb16fe7e4 Fixed bug that results in inconsistent diagnostics when surrounding an argument expression with parentheses. This addresses part of #8133. 2024-06-12 22:02:52 -07:00
Eric Traut
32f44d921a
Changed the behavior of double underscored symbols that are part of a module's namespace when that module is not a stub or in a "py.typed" package. Such symbols are no longer ignored, although they are considered private. This addresses #8131. (#8132) 2024-06-12 14:01:56 -07:00
PylanceBot
5d77369056
pull-pylance-with-pyright-1.1.367-9475931426 (#8123)
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rich Chiodo <rchiodo@users.noreply.github.com>
2024-06-12 11:02:27 -07:00
Eric Traut
63e0876cff Added support for deprecated objects that are instantiated prior to being used as a decorator. This allows for a factory usage pattern. This addresses #5953. 2024-06-12 10:48:37 -07:00
Eric Traut
6baa5b1368 Fixed a bug that causes warnings.deprecated not to work if the python version is 3.13. This was caused by recent changes to typeshed stubs. 2024-06-12 10:46:48 -07:00
Eric Traut
b0cee14316
Changed inference behavior for generator functions with no reachable yield or yield from statements. The "yield type" (the first type argument to Generator) is now inferred as Never in this case rather than None. This addresses #8127. (#8130) 2024-06-12 09:40:56 -07:00
Eric Traut
597c634157 Published 1.1.367 2024-06-11 19:40:49 -07:00
Eric Traut
f2e5ff87df
Simplified internal FunctionType.clone method. (#8121) 2024-06-11 19:29:53 -07:00
Eric Traut
1742c57f8d Added helper function to wrap type evaluator functions that cannot be safely interrupted by a cancellation exception. 2024-06-11 15:13:20 -07:00
Erik De Bonte
807b160a39
Discard TypeEvaluator if cancellation leaves partially-constructed function type in cache (#8118) 2024-06-11 15:02:36 -07:00
Eric Traut
d34d9ccc27 Fixed regression in the handling of certain __init__ methods with an explicit type annotation for self. 2024-06-11 13:27:02 -07:00
Eric Traut
add2193101 Fixed subtle bug in a test case that was resulting in a long hang during unit tests. 2024-06-11 13:11:42 -07:00
Eric Traut
0df185ebd4
Simplified handling of TypeVars used in bound objects for constructor methods. (#8119) 2024-06-11 12:50:12 -07:00
Eric Traut
0edcd2eecf
Fixed bug that results in parameter types being converted to Any when converting a NewType or dataclass constructor to a callable. This addresses #8116. (#8117) 2024-06-11 09:08:46 -07:00
Eric Traut
2b0a1d92dd Simplified FunctionType.cloneForSpecialization method. 2024-06-10 19:39:33 -07:00
Eric Traut
ec196107e2 Updated typeshed stubs to the latest version (to pick up recent fix in shutil.pyi). 2024-06-10 13:40:05 -07:00
Eric Traut
81d43e4c41 Added consistent use of getTypeVarScopeId accessor function. No functional change. 2024-06-10 13:37:17 -07:00
Eric Traut
45fcebfe2c
Changed the import resolution order to better reflect runtime behavior and match a proposed change to the typing spec. In particular, stdlib typeshed stubs are now resolved prior to site_packages. This addresses #8099. (#8100) 2024-06-09 07:57:44 -07:00
Eric Traut
e588c6f984 Fixed bug in previous commit the caused default include/exclude values not to be provided in the case where a pyproject.toml was present but contained no pyright section. Thanks to @augustelalande for catching this. 2024-06-08 23:06:00 -07:00
Eric Traut
4319e03b71 Fixed bug that led to divergent behaviors between pyrightconfig.json and pyproject.toml configurations. Specifically, default exclude patterns were not added in the case of pyproject.toml. This addresses #8102. 2024-06-08 22:24:45 -07:00
Eric Traut
238f70049f
Fixed bug that results in a false positive error under certain circumstances involving tuple type narrowing in a loop. This addresses #8095. (#8098) 2024-06-08 13:12:36 -07:00
Eric Traut
5a0ec2dda4 Fixed bug that causes Final annotation not to be honored when wrapped in an Annotated annotation. This addresses #8097. 2024-06-08 10:10:38 -07:00
Eric Traut
ec229aa925
Fixed a bug that results in incorrect (local) type evaluation of an instance variable with a declared type when assigned within a loop that uses an augmented assignment. This addresses #8090. (#8093) 2024-06-07 15:51:02 -07:00
Eric Traut
aad860332e Fixed bug that results in duplicate and (contradictory) diagnostic outputs in certain cases where reveal_type is used in a loop. 2024-06-07 14:36:54 -07:00