Commit Graph

5022 Commits

Author SHA1 Message Date
Eric Traut
1f16eb66b5 Fixed recent regression that results in a false positive when accessing an enum member from an instance of an enum class. This addresses #7926. 2024-05-15 20:26:27 -07:00
Eric Traut
6d79c5cada Fixed a bug that leads to a false positive error when first argument to super call is an instance of a metaclass. This addresses #7931. 2024-05-15 20:11:09 -07:00
Eric Traut
022b30a1f8 Fixed bug that results in a false negative syntax error when a PEP-695 type alias uses a keyword as a name. This addresses #7933. 2024-05-15 19:56:08 -07:00
Eric Traut
7ccf956b0f Published 1.1.363 2024-05-14 21:53:36 -07:00
Eric Traut
884301271b
Fixed a bug that results in incorrect type evaluation when a function parameterized with a TypeVarTuple is passed as an argument to another function parameterized with a TypeVarTuple. This addresses #7140. (#7920) 2024-05-14 21:48:53 -07:00
Eric Traut
eb2a1ef0ab
Removed some special-case logic that is no longer necessary. (#7919) 2024-05-14 21:03:47 -07:00
Eric Traut
468bae53e0
Changed the TypeVar scoping behavior for TypeVars that appear only within a Callable subtype within a function's declared return type. Previously, pyright scoped these TypeVars to the Callable rather than the function. This was due to issue #4285. I'm reversing this decision because it's not spec-compliant, creates a bunch of unnecessary complexity, and results in buggy behavior. This addresses #7722. (#7918) 2024-05-14 15:53:06 -07:00
Eric Traut
3ae32dc927
Fixed bug that resulted in false positive when evaluating a function call involving a TypeVarTuple under certain circumstances. This addresses #7820. (#7917) 2024-05-14 14:30:31 -07:00
Eric Traut
6c7470d51e
Fixed a bug that results in a false positive error when a decorator is applied to a property. This addresses #7740. (#7913) 2024-05-13 23:47:28 -07:00
Eric Traut
506f2c14dd
Fixed bug that results in incorrect type evaluation behavior within c… (#7912)
* Fixed bug that results in incorrect type evaluation behavior within class body of an enum class when one enum member is used to define another enum member. This involved a significant rewrite of the logic involving enum symbol evaluation. It addresses #7763.

* Add recursion protection.
2024-05-13 21:58:47 -07:00
Eric Traut
c477556fa1
Fixed bug that results in incorrect type narrowing for isinstance or issubclass type guard when the filter is a generic class whose type parameter has a default value. (#7905)
This addresses #7860.
2024-05-13 01:43:43 -07:00
Eric Traut
91dac9435e
Fixed bug that results in incorrect type narrowing for a tuple with determinate length when indexed with an out-of-bounds slice. This addresses #7864. (#7901) 2024-05-12 22:31:41 -07:00
Eric Traut
f7aba4ede4
Improved handling of constrained TypeVars when used with unary operators. This addresses #7874. (#7900) 2024-05-12 21:51:16 -07:00
Eric Traut
5817d275a2
Changed the type evaluation for type(Any) or type(x) where x is a value of type Any or Unknown. These now evaluate to type[Unknown]. (#7899) 2024-05-12 16:04:59 -07:00
Eric Traut
da446c7c6a Fixed recent regression that results in assert_type failure when a class is parameterized by a ParamSpec with a default value. This addresses #7878. 2024-05-12 00:22:58 -07:00
Eric Traut
8a5bfb975c Fixed false positive deprecatedTypingAliases deprecation for collections.abc.AbstractSet due to a recent change in typeshed stubs. This addresses #7875. 2024-05-12 00:06:29 -07:00
Eric Traut
bdb6b9dd51
Fixed bug that results in a false positive reportUnnecessaryComparison when a variable is used in a conditional expression and its type is a union that includes a Coroutine and a non-coroutine. This addresses #7881. (#7885) 2024-05-10 21:14:46 -07:00
Eric Traut
e045e1c0a2 Fixed bug that causes a false positive reportPrivateUsage error when a global or nonlocal binding is used within a class to access an outer-scoped variable. This addresses #7884. 2024-05-10 20:57:27 -07:00
Eric Traut
e654729d96 Fixed bug that resulted in diagnostics associated with the reportUnnecessaryTypeIgnoreComment check to not include the error code. This addresses #7883. 2024-05-10 16:32:17 -07:00
Eric Traut
255c13aef2 Deferred execution of type annotations (PEP 649) did not make it into Python 3.13 and has been deferred (again) until Python 3.14. Changing pyright's logic accordingly. 2024-05-08 21:02:35 -07:00
Eric Traut
7be85982d6 Updated manifest to reflect the correct default value for reportInvalidTypeForm. 2024-05-07 23:35:31 -07:00
Eric Traut
3af2bbc1f8 Published 1.1.362 2024-05-07 22:14:30 -07:00
Eric Traut
576d37151f
Added special-case handling for __init_subclass__ checks for classes that have ABCMeta as a metaclass. Previously, these were exempted from __init_subclass__ because ABCMeta has a custom __new__ method, but we know that this metaclass calls through to type.__new__ which calls __init_subclass__. This addresses #7819. (#7871) 2024-05-07 22:08:43 -07:00
Eric Traut
ecdea2caad Fixed a bug that resulted in a false negative when a Literal with multiple arguments is used in a value expression. It should be treated as a UnionType special form in this case. This addresses #7870. 2024-05-07 21:02:47 -07:00
Eric Traut
286fdf95f9 Fixed recent regression that resulted in incorrect type narrowing when a *args: P.args parameter was used in the expression len(args) >= x. This addresses #7866. 2024-05-07 20:56:48 -07:00
Andreas Runfalk
fa2779ec4c
varaiables -> variables typo fix for English and Korean translations. (#7862) 2024-05-07 08:58:10 -07:00
Eric Traut
c49af8f349
Changed interpretation of function definitions with (*args: Any, **kwargs: Any) to be ... in compliance with latest typing spec. This addresses #7848. (#7859) 2024-05-06 23:45:41 -07:00
Eric Traut
0ead803de9 Updated typeshed stubs to the latest version. 2024-05-06 22:19:18 -07:00
Eric Traut
3ead033827
Fixed incorrect type narrowing for a class pattern argument if the class is a generic whose type parameters have default values. This addresses #7855. (#7857) 2024-05-06 22:12:21 -07:00
Eric Traut
377958a0ee
Fixed false positive when a TypeVar appears within a function type comment. This addresses #7854. (#7856) 2024-05-06 21:05:19 -07:00
Eric Traut
e7cc55ad68
Fixed a bug that results in incorrect type evaluation for a variable that uses a nonlocal or global binding within an inner scope. Such a variable should never honor the narrowed type from the outer scope. This addresses #7838. (#7846) 2024-05-05 01:02:08 -07:00
Eric Traut
88a8d90ba8
Fixed recent regression with the TypeIs type guard that resulted in incorrect type narrowing in the negative (else) case. This addresses #7837. (#7845) 2024-05-04 23:19:08 -07:00
Eric Traut
9ab6b6ff14
Fixed a bug that results in incorrect type narrowing in the negative (fall-through) case when a match statement includes a class pattern with a runtime-checkable protocol class. This addresses #7823. (#7829) 2024-05-01 19:13:32 -07:00
Eric Traut
bdc4b2650f Fixed a crashing bug that results from an internal assertion failure when a generic class that uses PEP 695 syntax is located within an unreachable code block. This addresses #7828. 2024-05-01 18:33:20 -07:00
Eric Traut
66ebc186e1 Fixed a bug that results in incorrect type narrowing when a match statement uses an empty (zero-element) sequence pattern and the subject expression type is a tuple that potentially (but does not always) have a zero length. This addresses #7826. 2024-05-01 18:03:55 -07:00
PylanceBot
211f8d12fc
pull-pylance-with-pyright-1.1.361-8904242021 (#7815)
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rich Chiodo <rchiodo@users.noreply.github.com>
2024-05-01 09:40:12 -07:00
Eric Traut
4ea3cd6a1f Addressed a performance issue when indexing into a value that has a type consisting of a union of many (dozens or hundreds) of tuple types. This addresses #7813. 2024-04-30 22:22:47 -07:00
Eric Traut
a042135776 Minor code improvement. Changed the name of an inner-scope variable to avoid shadowing an outer-scoped variable. No functional change. 2024-04-30 22:21:43 -07:00
Eric Traut
ab84d414f0 Published 1.1.361 2024-04-30 18:52:30 -07:00
Eric Traut
de5a4f8d4c
Fixed bug that produces incorrect output when converting to a textual representation the type type[Foo] where Foo is a type alias. This addresses #7806. (#7809) 2024-04-30 09:27:26 -07:00
Eric Traut
582a93e3fe
Fixed a bug that results in a false negative when an Unpack is used in a union. This isn't allowed. (#7805) 2024-04-30 01:46:43 -07:00
Eric Traut
42962e796f Split out type evaluator tests into more files and rebalanced them to take advantage of machines with more cores. On my new MacBook Pro, this drops the time to run tests from 45s to 23s. 2024-04-29 22:23:50 -07:00
Eric Traut
01c512ee7e Fixed bug that resulted in incorrect evaluation of an identifier used in a method parameter type annotation if it shadows a forward reference in a class scope when the method is using PEP 695 type parameters. This addresses #7800. 2024-04-29 22:06:54 -07:00
Eric Traut
0af66f4468
Fixed a bug that results in incorrect type evaluation when a global (module-scoped) variable is captured within an inner scope and the variable is not modified anywhere below the inner scope. It's possible in this case for the variable to be modified by code outside of the module. This addresses #7780. (#7803) 2024-04-29 16:16:32 -07:00
Eric Traut
fcf5b372be Changed the tokenizer so it is bug-for-bug compatible with the CPython tokenizer in versions 3.10 and newer in the case where a backslash (continuation character) is located by itself on a line. This addresses #7799. 2024-04-29 16:00:54 -07:00
Eric Traut
1aed0e3261
Fixed a false negative that occurs when reassigning a Final variable within a class body. This addresses #7797. (#7801) 2024-04-29 15:36:45 -07:00
Eric Traut
4c1eb615af
Fixed a bug that results in a false positive error when Callable() is used as a class pattern and the subject type is Any or Unknown. This addresses #7794. (#7796) 2024-04-28 18:44:26 -07:00
Eric Traut
556608dffd Fixed a bug that leads to an infinite loop when performing protocol matching under certain circumstances that involve recursive protocol definitions. This addresses #7786. 2024-04-27 19:33:17 -07:00
Eric Traut
47c53f9b5b Fixed a bug that results in a false positive error when using __extra_items__ (PEP 728) with a TypedDict imported from typing_extensions. This addresses #7784. 2024-04-27 15:52:43 -07:00
Eric Traut
2743ba5cbf
Fixed a bug that led to poor performance (effectively a hang) if an unannotated function is called through many (greater than 8) call expressions within a loop using different literal-value arguments each time. This addresses #7791. (#7792) 2024-04-27 15:45:29 -07:00
Eric Traut
0a8e1b7af6 Fixed documentation and json schema for reportMissingTypeStubs default. This addresses #7789. 2024-04-26 21:40:57 -07:00
Eric Traut
6950622347
Issue7779 (#7781)
* Changed `TypeIs` to use the same logic as `isinstance` type narrowing logic for consistency. This addresses #7767, #7760, and #7647.

* Fixed bug that results in a false positive error when a `yield` statement is used within a lambda following a function. This addresses #7779.
2024-04-26 09:51:58 -07:00
Eric Traut
96d0145763
Changed TypeIs to use the same logic as isinstance type narrowing logic for consistency. This addresses #7767, #7760, and #7647. (#7777) 2024-04-25 22:19:04 -07:00
Eric Traut
c2203b9aa7
Fixed bug that resulted in incorrect bidirectional type inference when calling a constructor for a generic class that defines no __new__ or __init__ method. This addresses #7764. (#7776) 2024-04-25 21:10:10 -07:00
Eric Traut
c640765de5 Changed logic that synthesizes the constructor methods for a NamedTuple subclass (using the class syntax) so the __new__ method contains parameters based on field names and the __init__ method contains a general *args: Any, **kwargs: Any parameter signature. Previously, this was swapped, but the new way is more faithful to the runtime. This addresses #7769. 2024-04-25 20:30:30 -07:00
Eric Traut
7194375bff
Fixed bug caused by incorrect synthesis of item and keys attributes for named tuple classes. This addresses #7768. (#7775) 2024-04-25 19:50:12 -07:00
Eric Traut
547a15021b
Fixed a bug that results in a false negative when using bidirectional type inference to evaluate the type of a lambda expression if the expected type is a union of two or more callables. This addresses #7772. (#7773) 2024-04-25 19:37:15 -07:00
Erik De Bonte
4bc8428d75
Follow-up pull from Pylance (#7766) 2024-04-25 07:23:15 -07:00
PylanceBot
ffcd90bb91
Pull Pylance with Pyright 1.1.360 (#7761)
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-24 17:58:06 -07:00
Eric Traut
f4afe405cd Published 1.1.360 2024-04-23 22:00:23 -07:00
Eric Traut
e5c0b59c77 Fixed bug that leads to incorrect metatype for a class object that is created by calling the metaclass with a two-argument form. 2024-04-23 21:58:46 -07:00
Eric Traut
d33a1051dd
Fixed bug that leads to false negative when binding an object to an overloaded method where all of the overloads have incompatible self parameter types. This addresses #7742. (#7755) 2024-04-23 21:47:13 -07:00
Eric Traut
7c8e8ba8e0 Updated typeshed stubs to the latest version. 2024-04-23 21:26:05 -07:00
Eric Traut
400bb92da0
Redesigned the handling of PEP 695-style type parameter scoping to better match the CPython runtime implementation. This addresses #7716 and #7737. (#7754) 2024-04-23 21:05:07 -07:00
Eric Traut
3875288287
Fixed a bug that results in a false positive error when bidirectional type inference is used for a dictionary comprehension when the expected type is a union. This addresses #7741. (#7751) 2024-04-23 00:01:47 -07:00
Eric Traut
cd483dcb90
Fixed bug in protocol matching that results in a false positive when the subject object is a dataclass that contains a callable. It should be considered an instance member in this case, so it should not be bound to the class. This addresses #7735. (#7749) 2024-04-22 20:47:48 -07:00
Eric Traut
d1461cee9f
Changed behavior to no longer exempt unguarded access to not-required TypedDict member within a try or with block. Previously, such errors were exempt, but this is inconsistent with other type checks in pyright which eschew the practice of using exception handling for normal code flow. This addresses #7714. (#7748) 2024-04-22 18:39:45 -07:00
Eric Traut
73d894c1be
Fixed recent regression that incorrectly narrowed the type of kwargs when used in a type guard of the form if "a" in kwargs. This addresses #7731. (#7747) 2024-04-22 18:19:10 -07:00
Eric Traut
419a8f41c1
Fixed recent regression that affected unannotated __call__ methods in a metaclass. This change aligns pyright's behavior to the typing spec. It addresses #7717. (#7746) 2024-04-22 17:50:11 -07:00
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
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
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
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
Eric Traut
a33feda80f
Fixed bug that results in false negative when a __new__ or __init__ method cannot be bound without a type violation. This bug was found when writing a chapter on "constructors" for the typing spec. (#7573) 2024-03-27 11:56:52 -06:00
Eric Traut
436c72c0b7 Added support for negative (fall-through) type narrowing for subject subexpressions in match statement when subject consists of a tuple expression and patterns exhaustively match the tuple. This addresses #7568. 2024-03-27 09:51:26 -06:00
Eric Traut
b3723da1c5 Fixed bug that results in a false positive error when explicitly calling __new__ on a dataclass, namedtuple, or TypedDict. These classes all require synthesized __new__ methods. This addresses #7567. 2024-03-27 08:32:46 -06:00
PylanceBot
6652c4a818
pull-pylance-with-pyright-1.1.356-8444976018 (#7566)
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-03-26 18:26:35 -07:00
Eric Traut
9f02004791 Published 1.1.356 2024-03-26 18:48:57 -06:00
Eric Traut
1001904ff5 Fixed a bug that results in a false positive reportImplicitOverride diagnostic if the class derives from an Unknown or Any class. This addresses #7560. 2024-03-26 08:28:44 -06:00
Eric Traut
6ef2ca1b27 Updated typeshed stubs to the latest version. 2024-03-25 17:31:40 -06:00
Heejae Chang
1110ff90e4
push pylance to pyright (#7558) 2024-03-25 14:50:25 -07:00
Eric Traut
7cf91f78a2 Changed the logic for metaclass instance variable lookups to ignore the lookup if the metaclass MRO contains an unknown class. This addresses #7556. 2024-03-25 09:02:06 -06:00
Eric Traut
fe41569755
Fixed a bug that results in a false positive when a class-scoped TypeVar used within a method has a default that refers to another class-scoped TypeVar. This addresses #7553. (#7554) 2024-03-24 16:03:00 -06:00
Eric Traut
69a9151674 Added check for the use of a non-runtime-checkable protocol class in a class pattern. This generates an exception at runtime. This addresses #7551. 2024-03-24 11:46:16 -06:00
Eric Traut
bb95091f1c
Fixed bug that results in incorrect type narrowing in the negative (fall-through) case when a runtime-checkable protocol class is used as a class pattern with arguments within a match statement. This addresses #7550. (#7552) 2024-03-24 11:41:24 -06:00
Eric Traut
3da27fd549 Fixed bug that resulted in a false positive error if a PEP-695 type statement uses a type parameter and encloses the RHS in quotes. This addresses #7538. 2024-03-21 14:12:49 -06:00
Erik De Bonte
a6e787fd4e
Use hex char codes and show code points for surrogate pairs (#7541) 2024-03-21 12:44:55 -07:00
Erik De Bonte
7f468b8c5b
Update Unicode range tables to match Unicode 15.1 (#7539) 2024-03-21 12:16:18 -07:00
Eric Traut
52a47010b9
Tweaked bidirectional type inference behaviors for lists to improve certain inference cases. This addresses #7527. (#7528) 2024-03-20 13:06:06 -06:00
Eric Traut
01eaa6fa64 Fixed bug that results in a false positive error when a class-scoped TypeVar with a default that references another class-scoped TypeVar is used in a method signature in that class. This addresses #7525. 2024-03-20 11:36:51 -06:00
Eric Traut
a2831b7338 Published 1.1.355 2024-03-20 00:07:43 -06:00
Eric Traut
8c0f8a968a
Fixed bug that results in false positive error when a __new__ method in a metaclass uses PEP 692 (unpacked TypeDict) to annotate its **kwargs parameter. This addresses #7514. (#7518) 2024-03-19 03:26:02 -06:00
Eric Traut
02a66c5e66
Expanded handling of python versions to handle more than just major/minor version numbers. Pyright now handles micro, releaseLevel, and serial numbers as well. This addresses #7132. (#7510) 2024-03-18 00:56:18 -06:00
Eric Traut
5a64ddfe5e
Fixed a bug that results in a false positive in a complex situation that involves generic protocols, properties, and mix-in classes. This addresses #7400. (#7506) 2024-03-17 10:36:21 -06:00
Eric Traut
c7beec11c2 Fixed bug that results in a false positive "overload implementation does not match overloads" diagnostic when positional-only and keyword-only parameters are involved. This addresses #7473. 2024-03-16 17:14:51 -06:00
Eric Traut
b0d18cff0c Fixed bug that results in a false positive error when a base class defines a writable property and a subclass writes to the property. This addresses #7478. 2024-03-16 13:22:12 -06:00
Eric Traut
cb2c493dab Fixed a bug that results in a false positive error in certain circumstances involving a TypeVarTuple used within an overload. This addresses #7502. 2024-03-16 13:14:06 -06:00
Eric Traut
0f9dc4758f
Fixed bug that results in a false negative when overriding a method that has keyword parameters with a method that has a *args parameter. This addresses #7480. (#7501) 2024-03-16 11:48:08 -06:00
Eric Traut
7320a6d31a
Improved validation for except and except* statements to catch some previously-undetected invalid cases. This addresses #7483. (#7500) 2024-03-16 10:28:55 -06:00
Eric Traut
8115955fae
Fixed bug that results in false positive when a list or set expression is evaluated using bidirectional type inference when the expected type is MutableSet or MutableSequence. This addresses #7498. (#7499) 2024-03-16 00:27:38 -06:00
Eric Traut
114817af10
Updated typeshed stubs to the latest. This version of typeshed replaces the older-style positional-only parameters with PEP 570 syntax. (#7493) 2024-03-15 08:48:52 -06:00
Eric Traut
ca142066b3
Fixed bug that results in false positive when implicitly specializing a class parameterized by a TypeVarTuple when there is no default. This addresses #7489. (#7491) 2024-03-15 01:00:00 -06:00
Eric Traut
c6f8b83c4a Renamed typeUtils function for consistency. 2024-03-14 23:53:21 -06:00
Eric Traut
18243af812
Fixed bug that results in a false negative when a TypeAliasType object is used in a class pattern. This addresses #7485. (#7486) 2024-03-14 13:43:02 -06:00
Eric Traut
d7dc004c78 Fixed a bug that results in incorrect type evaluation if a list expression includes a generator expression. This addresses #7481. 2024-03-14 10:54:44 -06:00
PylanceBot
6c4b329177
pull-pylance-with-pyright-1.1.354 (#7476)
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-13 11:03:37 -07:00
Eric Traut
0a73f4b0f5 Published 1.1.354 2024-03-13 09:22:00 -06:00
Eric Traut
0334a44b83 Fixed a bug that made locale overrides through environment variables no longer work on node 21. This change removes the ability to override the localized language through the use of the global navigator object. This previously applied only to browser, but now node 21 supports this, which means that pyright users had no way to override it. If the pylance team wants localization to work in a browser, they'll need to find a better way to abstract this so it doesn't break pyright. This addresses #7439. 2024-03-12 00:38:05 -06:00
Eric Traut
6a042f7b58
Added new reportUnhashable diagnostic rule. This addresses #7462. (#7464) 2024-03-12 00:34:58 -06:00
Eric Traut
3ccd7b87b5
Fixed a bug that results in a false negative when a class explicitly inherits from a protocol that defines an instance variable but the child re-declares as a ClassVar without an explicit type. This addresses #7455. (#7463) 2024-03-12 00:29:01 -06:00
Rich Chiodo
06bc912e38
Save some memory in token creation (#7434)
* Save some memory in token creation

* Found another 200k

* Fix wrong way to check for undefined

* Back out unnecessary regex change

* Remove 'ExceedsMaxSize'
2024-03-11 09:30:48 -07:00
Eric Traut
6e73064841
Fixed a bug that results in a false positive under certain circumstances when defining a type alias using the old typing.TypeAlias annotation. This addresses #7457. (#7458) 2024-03-11 09:40:44 -06:00
Eric Traut
0ff8b5aa1f
Changed the behavior when accessing a class attribute from a generic class that is not specialized. The class is now automatically specialized in the case using default type parameter values (from PEP 696) or Unknown. This change is required for conformance with PEP 696. It addresses #7445. (#7454) 2024-03-11 00:51:05 -06:00
Eric Traut
33cab2aefe Fixed bug that resulted in a false positive under certain circumstances when a constrained TypeVar is used as the default for another constrained TypeVar. This addresses #7446. 2024-03-10 16:17:57 -06:00
Eric Traut
d1b2f3331b Fixed style issue. 2024-03-10 14:58:00 -06:00
Eric Traut
37ecc8d0bb Fixed bug that resulted in false negative when narrowing a constrained or bound TypeVar with a complex() or float() class pattern. This addresses #7449. 2024-03-10 14:30:45 -06:00
Eric Traut
1ff3820b34 Fixed bug that results in false positive when a generic class or type alias uses a TypeVarTuple followed by one or more ParamSpecs that have default values. This addresses #7444. 2024-03-10 13:47:23 -06:00
Eric Traut
bbd78d5090 Added check for generic classes and type aliases that include a TypeVarTuple followed by a TypeVar that has a default value. This is illegal according to PEP 696. This addresses #7443. 2024-03-10 12:41:44 -06:00
Eric Traut
1d658bb835 Fixed two bugs that resulted in false negatives when redefining a constant variable with a non-variable symbol and when redefining a Final variable with a non-variable symbol. This addresses #7440. 2024-03-09 18:07:57 -07:00
Eric Traut
209fac9a2c Enhanced handling of type function when it is passed a class. Pyright previously evaluated this as Any, but now it returns the class' metaclass. This addresses #7437. 2024-03-09 08:34:13 -07:00
Eric Traut
39960f39e4
Fixed a bug that resulted in an incorrect type evaluation when an augmented assignment is used within an inner-scoped function to add a constant to a variable. Literal math should not be used in this case. This addresses #7431. (#7436) 2024-03-08 21:59:50 -07:00
PylanceBot
a612aa9871
[PylanceBot] Pull Pylance with Pyright 1.1.353 (#7428)
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-08 11:06:09 -08:00
Eric Traut
114501e336 Published 1.1.353 2024-03-07 21:15:42 -07:00
Eric Traut
a434dfb535
Fixed bug that resulted in a false negative when a possibly-unbound variable is captured by an inner scope under certain circumstances. This addresses #7384. (#7427) 2024-03-07 20:12:20 -07:00
Eric Traut
38123df9e9
Fixed a bug that results in incorrect type narrowing behavior for member access expressions under certain circumstances. This addresses #7414. (#7426) 2024-03-07 18:38:38 -07:00
Eric Traut
34faf10e13 Removed inappropriate use of typeAtStart value in code flow engine. 2024-03-07 18:05:59 -07:00
Eric Traut
e39bc677af Further simplified interface to code flow engine. No functional change. 2024-03-07 18:05:59 -07:00
Erik De Bonte
6a8ae9215a
Show str method docstrings when called on LiteralString (#7388) 2024-03-07 13:10:27 -08:00
Eric Traut
bf0388ba57 Fixed a bug in the isinstance type guard logic. It was not properly handling tuples that included unions. This addresses #7422. 2024-03-07 13:45:13 -07:00
Eric Traut
1536aa5f4b Simplified interface to code flow engine by moving some parameters to options object. No functional change. 2024-03-07 01:13:27 -07:00
Eric Traut
aea1839e7b
Fixed hard-coded type information for module attribute __package__. It should be str | None rather than str. This addresses #7408. (#7409) 2024-03-06 09:23:07 -07:00
Eric Traut
e8e8464038 Fixed a regression that caused the signature help provider to not display the __new__ method of a constructor if it is overloaded. This addresses #7405. 2024-03-05 15:56:15 -07:00
Eric Traut
f27b71e236 Fixed a bug that results in incorrect type evaluation when an index expression is assigned a value within a doubly-nested loop under certain circumstances. This addresses #7381. 2024-03-03 14:11:26 -07:00
Eric Traut
9dce19cc87
Fixed a bug that results in a false positive error when expanding the type arguments to a TypeVarTuple under certain circumstances. This addresses #7389. (#7390) 2024-03-03 00:35:43 -07:00
Eric Traut
c64f9b3f1f
Improved support for instance variables whose type is declared in a metaclass. Pyright now honors this type and enforces type consistency in derived classes. This addresses #7372. (#7387) 2024-03-01 11:28:07 -07:00
Eric Traut
97267a53d6 Added check for inappropriate use of Annotated passed as second argument to NewType call. This addresses #7383. 2024-03-01 09:15:26 -07:00
Eric Traut
9fd49f6a13
Fixed a bug that leads to a false positive error when a match statement is used in a loop and the subject expression is potentially narrowed as a result of the match statement. This addresses #7371. (#7377) 2024-02-29 12:15:32 -07:00