Commit Graph

7556 Commits

Author SHA1 Message Date
Eric Traut
19183640d8 Fixed a bug in bindFunctionToClassOrObject function that resulted in incorrect results when binding a class object to a method in its metaclass. Also renamed the treatConstructorAsClassMethod parameter for clarity. 2024-04-13 18:27:30 -07:00
Eric Traut
975c846895
Fixed bug that results in incorrect type evaluation when solving a ParamSpec type when there are multiple constraints provided. (#7692) 2024-04-13 17:34:02 -07:00
Eric Traut
567d025f48
Added missing check for the errant use of class-scoped type variables in a type annotation for the "self" parameter within an "__init__" method. The typing spec now clarifies that this is illegal and should generate an error. This addresses #7683. (#7691) 2024-04-13 09:49:17 -07:00
Eric Traut
d7dce3b6a8
Modified handling of annotated self parameter in __init__ method when evaluating constructor call so pyright conforms to the latest typing spec. This addresses #7682. (#7690) 2024-04-13 09:31:11 -07:00
Eric Traut
dfe428190c
Fixed bug that results in a spurious reportAbstractUsage error when an abstract class is captured through a type[T]. This addresses #7680. (#7681) 2024-04-12 23:10:30 -07:00
Eric Traut
92f2284d24 Changed behavior when evaluating the upper bound expression, value constraints expression, or default expression for a PEP-695 type parameter. At runtime, these are always evaluated in a deferred manner even if they are not quoted. Pyright now follows the runtime behavior. This addresses #7678. 2024-04-12 14:08:05 -07:00
Eric Traut
f2e277aa5c
Fixed recent regression that results in a false positive error when applying a @property decorator to a method that has already had a decorator applied to it. This addresses #7667. (#7671) 2024-04-11 20:44:46 -07:00
Eric Traut
dd09712579
Extended type narrowing logic for in and not in operators that target TypedDicts to also support constrained TypeVars that use TypedDicts as value constraints. This addresses #7666. (#7670) 2024-04-11 17:53:24 -07:00
Eric Traut
8c7e67d3c7
Fixed a bug that leads to inconsistent behaviors when an assignment leads to a type violation. When assigning to a local variable, the target expression is not "narrowed" to include the assigned type in this case. The new behavior applies this same behavior when assigning to instance or class variables. This addresses #7664. (#7669) 2024-04-11 17:53:09 -07:00
Eric Traut
c212c2374f More diagnostic message improvements: switched from "cannot assign to type" to "incompatible with type" for consistency and clarity. 2024-04-11 17:24:15 -07:00
Eric Traut
27e6b0e054 Improved some diagnostic messages, moving away from the term "member" to prefer "attribute". This partly addresses #7664. 2024-04-11 16:52:10 -07:00
Erik De Bonte
d45ea4cea8
Push pylance changes to pyright (#7663)
Co-authored-by: Bill Schnurr <bschnurr@microsoft.com>
Co-authored-by: HeeJae Chang <hechang@microsoft.com>
Co-authored-by: Erik De Bonte <erikd@microsoft.com>
Co-authored-by: Rich Chiodo <rchiodo@microsoft.com>
Co-authored-by: Stella Huang <stellahuang@microsoft.com>
Co-authored-by: Kacie Kang <jikang@microsoft.com>
2024-04-10 14:48:46 -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
989ee29c0b Published 1.1.358 2024-04-09 19:31:43 -07:00
Eric Traut
ad1c378268 Added an error message for a Literal type annotation that includes a string with a named unicode escape sequence. These are not supported. 2024-04-09 17:26:42 -07:00
Heejae Chang
bd08098c5d
Skip unnecessary py.typed file exist checks. (#7652)
* skip unnecessary py.typed file exist checks.

* passed wrong uri

* PR feedbacks

* more comments

* PR feedbacks
2024-04-09 14:36:43 -07:00
Erik De Bonte
ed92822a64
Simplify editable install docs (#7643) 2024-04-08 18:58:48 -07:00
Eric Traut
e9d19b5520
Improved error handling for quoted annotations. Bytes, raw strings, and f-strings are not allowed according to the typing spec. This addresses #7640. (#7641) 2024-04-08 12:40:40 -07:00
Eric Traut
d16990abc1
Fixed bug that results in inconsistent type narrowing on assignment based on whether the assignment occurs within the same statement that includes the (declared) type annotation for the variable and whether the type annotation is provided as a type comment. This addresses #7537. (#7638) 2024-04-07 23:13:02 -07:00
Eric Traut
e65ac3854d
Fixed a bug that results in a false negative when a generic function returns a Callable type that is specialized to include a live (in-scope) type variable. This addresses #7542. (#7634) 2024-04-07 11:36:31 -07:00
Eric Traut
3b70417dd5
Fixed bug that results in incorrect type evaluation in cases where a generic function returns a callable, and the function is called with a higher-order generic function as an argument. This addresses #7386. (#7630) 2024-04-06 23:16:24 -07:00
Eric Traut
cfefcf49f5 Updated typeshed stubs to the latest version. 2024-04-06 17:50:34 -07:00
Eric Traut
628e246887
Fixed a bug that results in a false positive error under certain circumstances when a TypeVar or TypeVarTuple is being solved with literal values in both an invariant and non-invariant context. This addresses #7562. (#7629) 2024-04-06 14:41:22 -07:00
Eric Traut
4149eb3eda
Fixed bug that results in an intermittent false positive "circular dependency" error for fields within a dataclass. This addresses #7516. (#7625) 2024-04-05 22:03:03 -07:00
Eric Traut
39dfca8acd Added accessor method for class symbol table. This is in preparation for a bug fix for #7516. 2024-04-05 21:52:53 -07:00
Eric Traut
6d1a5fd9f7
Added support for narrowing of subject subexpression within a match statement for references to the subexpression after the completion of the match statement. This addresses #7620. (#7621) 2024-04-04 23:05:55 -07:00
Eric Traut
627d3ded61 Modified the handling of enum class attributes so those with private (mangled) names are exempted from being considered enum members. This reflects the runtime behavior. This addresses #7619. 2024-04-04 16:47:01 -07:00
Eric Traut
aff916f0cd Added optimization for TypedDict type assignments. Under certain circumstances (e.g. when comparing large unions of TypedDict types), this can save significant time. This addresses #7617. 2024-04-04 14:43:56 -07:00
Eric Traut
476447cb65
Fixed a bug that results in incorrect type evaluation when a sequence pattern in a match statement includes a * element and the subject includes a tuple with an element with indeterminate length. This addresses #7613. (#7616) 2024-04-04 10:06:35 -07:00
Eric Traut
26db037205 Fixed non-compliance issue with TypeIs, which is documented to have an invariant type parameter. This addresses #7615. 2024-04-04 08:27:31 -07:00
Erik De Bonte
727bce6c01
Pull Pylance with Pyright 1.1.357 (#7610) 2024-04-03 17:28:33 -07:00
Eric Traut
1eb0c99f2c Eliminated the need to retain a reference to the file contents in the parse tree. This helps pave the way for dropping the file contents altogether for memory savings. 2024-04-03 11:52:21 -07:00
Rich Chiodo
ed1dbe2132
Fix crash when imports are not resolved (#7608)
* Fix crash when imports are not resolved

* Fix other usages of resolvedPath
2024-04-03 11:23:11 -07:00
Eric Traut
8752be7a73 Published 1.1.357 2024-04-03 07:45:28 -07:00
Eric Traut
b6c8b7f73d Fixed a bug that results in incorrect inferred parameter types for an unannotated method in a subclass when the parent class method contains function-scoped TypeVars. This addresses #7606. 2024-04-03 07:41:55 -07:00
Rich Chiodo
4106a09001
Share heap usage numbers to support cache cleanup in VS code (#7605)
* Pass shared array buffer around for shared heap stats

* Put back skip logic for background analysis

* Review feedback
2024-04-02 16:49:40 -07:00
Eric Traut
5fd8830666
Refactored tokenizer and parser output to help reduce the amount of memory needed. (#7602) 2024-04-02 16:01:29 -07:00
Eric Traut
0b30e87de2 Improved return result for synthesized get method for closed TypedDict classes (as defined in PEP 728). 2024-04-02 07:47:16 -07:00
Eric Traut
dab9c8f20b Improved diagnostic message for access to unknown member in the case where the user probably meant to access an item in a TypedDict but used a member access expression rather than an index expression. This addresses #7579. 2024-03-31 22:31:06 -07:00
Eric Traut
2b29345060 Improved comment in completion provider. No functional change. 2024-03-31 22:30:05 -07:00
Eric Traut
7bc313e062
Fixed a bug that results in a false positive error when an unpacked TypeVarTuple is used in a function defined with PEP-695 syntax. This addresses #7588. (#7599) 2024-03-31 21:47:03 -07:00
Eric Traut
efb49124fb
Fixed inconsistent handling of literal values in a list comprehension. This addresses #7586. (#7598) 2024-03-31 16:15:11 -07:00
Eric Traut
b085a2669a Changed the handling of Final variables (that are not explicitly marked ClassVar) within dataclass class bodies. This is consistent with the runtime and [this proposed change to the typing spec](https://github.com/python/typing/pull/1669). 2024-03-31 15:07:14 -07:00
Eric Traut
7997351885
Enhanced discriminated class support to include not only literal field values but also None. This addresses #7590. (#7592) 2024-03-29 21:45:18 -06:00
Eric Traut
bf4ddb357b Updated documentation for #7590. 2024-03-29 21:40:57 -06:00
Eric Traut
e4f3d618d8 Fixed bug that results in a type not being narrowed when using the K in TD type guard pattern (where TD is a TypedDict and K is a literal key). Narrowing was skipped if the RHS operand was not a simple identifier. This addresses #7589. 2024-03-29 21:37:37 -06:00
Eric Traut
0668724375 Refactored createFunctionFromConstructor for readability and maintainability. No functional change. 2024-03-28 11:28:21 -06:00
Eric Traut
c29473ab0f Enhanced dictionary type evaluation to support dictionary items that overwrite previous dictionary items. Only the last value type is now considered, so if previous values (which are overwritten) would otherwise violate typing rules, this no longer generates a type error. 2024-03-27 21:56:26 -06:00
Eric Traut
8312bbee9d
Fixed a type hole when a dictionary expression includes a dictionary expansion operator that acts on a non-closed TypedDict. This addresses #7577. (#7582) 2024-03-27 21:33:06 -06:00
Eric Traut
fc41d35343
Fixed a bug that results in incorrect type narrowing of enums that derive from enum.Flag. In this case, we can't use enum expansion to a union of literals. This addresses #7576. (#7580) 2024-03-27 18:04:50 -06:00