Commit Graph

7526 Commits

Author SHA1 Message Date
Eric Traut
f22576f0f8 Moved check for invalid use of class-scoped TypeVar within a self annotation in __init__. It was previously reported under reportGeneralTypeIssues, but it's now moved to reportInvalidTypeVarUse. This was done to help typeshed maintainers migrate away from this pattern. https://github.com/python/typeshed/pull/11780#issuecomment-2070101577 2024-04-22 09:51:32 -07:00
InSync
687fadef75
Fix a few typos in docs/configuration.md (#7739)
* Fix a typo

* Add missing "default" clause
2024-04-22 09:09:37 -07:00
Eric Traut
c7168d7068 Added support for @deprecation messages for decorators that wrap a function in a callable object. The deprecated message is now propagated through the ParamSpec and the __call__ method. This addresses #7732. 2024-04-21 21:22:07 -07:00
Heejae Chang
0127fd67ad
log type evals perf when option is on (#7729) 2024-04-19 18:11:58 -07:00
Heejae Chang
a8399d3933
Don't use Uri.Empty for default workspace. (#7654)
* Don't use Uri.Empty for default workspace.

* addressed PR feedback
2024-04-17 16:31:52 -07:00
Erik De Bonte
69ded75d4b
Loc update from Pylance (#7720) 2024-04-17 13:00:35 -07:00
Erik De Bonte
fc1b547130
Push pylance changes to pyright (#7719)
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-17 11:46:31 -07:00
Eric Traut
cc3467fda4 Published 1.1.359 2024-04-16 17:15:25 -07:00
Eric Traut
8912c884ce
Fixed bug that results in false positive error under certain circumstances that involve unions of TypeVars in an invariant context. This addresses #6957. (#7709) 2024-04-15 23:09:21 -07:00
Eric Traut
8a7aed5983
Added a check for the case where a frozen dataclass overrides a field from its parent class but doesn't provide a default value (where its parent does). This can result in a type violation if the parent's default value is not compatible with the child's (covariant) field type. This addresses #7702. (#7704) 2024-04-14 11:39:26 -07:00
Eric Traut
b1c436842c
Changed behavior of conversion from class constructor to callable to conform to honor return type of the __new__ method. This addresses #7687. (#7701) 2024-04-13 23:11:53 -07:00
Eric Traut
71a3b60960
Changed behavior of conversion from class constructor to callable to conform to honor the annotated type of self in the __init__ method. This addresses #7688. (#7699) 2024-04-13 22:06:32 -07:00
Eric Traut
43fe9a7e2c
Changed behavior of conversion from class constructor to callable to conform with the typing spec in the case where the __new__ method of the class returns a value that indicates the __init__ method should be ignored. This addresses #7686. (#7698) 2024-04-13 21:41:56 -07:00
Eric Traut
74880b87d3 Fixed broken build. I forgot to check in a test change. 2024-04-13 21:18:03 -07:00
Eric Traut
653e1609e7 Modified behavior in constructor call code that previously applied some (now non-compliant) heuristics to reconcile a metaclass __call__ method with a __new__ method. The new behavior is now compliant with the typing spec. 2024-04-13 21:07:40 -07:00
Eric Traut
9d87fe1079
Changed the behavior when invoking constructor for type[T] where T is a TypeVar with no explicit upper bound (and therefore has an implicit upper bound of object). According to the newly-clarified typing spec, this should enforce the constructor signature of object. (#7697) 2024-04-13 21:05:39 -07:00
Eric Traut
7f46092aef
Fixed a bug that leads to a false negative when an unparenthesized assignment expression is used in a dictionary key within a dictionary expression or comprehension. This addresses #7694. (#7696) 2024-04-13 20:40:30 -07:00
Eric Traut
2e537e9a0f
Updated logic for converting a class constructor to a callable to conform to the newly-updated typing spec. This addresses #7684 and #7685. (#7693) 2024-04-13 20:16:47 -07:00
Eric Traut
00d8f81a1c Fixed a bug that results in incorrect type evaluation when assigning a function with a NoReturn return type to a Callable[..., T]. 2024-04-13 18:39:18 -07:00
Eric Traut
5c480848ce Refactored the logic related to conversion of a class constructor to a callable in prep for further bug fixes. No functional change. 2024-04-13 18:33:33 -07:00
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