Eric Traut
4c49f1b8cd
Improved type printer (the component that converts an internal type to textual format for diagnostic messages) so it better handles special forms like Literal
or unions when used in a value expression. This partly addresses #7547 .
2024-05-21 10:49:29 -07:00
Eric Traut
1027400ac0
Fixed bug that leads to a false negative when calling a callback function that returns a callable with a generic parameter type. This addresses #7718 . ( #7965 )
2024-05-21 01:47:44 -07:00
Eric Traut
582ead0aa0
Updated typeshed stubs to the latest version.
2024-05-21 01:02:48 -07:00
Eric Traut
e4e48b9d26
Added test case for #7250 , which was fixed by the same fix for #7141 .
2024-05-21 00:02:51 -07:00
Eric Traut
39962012cb
Added test case for previous commit.
2024-05-20 23:58:55 -07:00
Eric Traut
9f76ed501e
Fixed a bug that resulted in an infinite loop when a function that uses an *args: *Ts
parameter is passed as an argument to itself. This partially addresses #7141 . ( #7964 )
2024-05-20 23:35:11 -07:00
Eric Traut
51225759d2
Fixed regression that results in incorrect type evaluation for annotations that involve nested protocols (such as P[P[T]]
). This addresses #6767 . ( #7963 )
2024-05-20 19:34:46 -07:00
Eric Traut
7fb7b4158d
Added support for recent addendum to typing spec that provides a special case for dataclasses so ClassVar
and Final
can be used together to distinguish between a regular Final
instance variable and a ClassVar
that is also Final
. This addresses #7959 . ( #7962 )
2024-05-20 15:52:34 -07:00
Eric Traut
d1515002d9
Fixed a bug in the dataclass "converter" support that resulted in an error if the converter is tuple
. This addresses https://github.com/microsoft/pylance-release/issues/5391 .
2024-05-20 12:53:20 -07:00
Eric Traut
dbac83d45c
Fixed a bug that results in a false negative when a generic function has a parameter with a generic type and a default argument value. This could lead to a typing hole when considering subtyping rules for callables. This addresses #7288 . ( #7954 )
2024-05-19 21:34:08 -07:00
Eric Traut
0b7860b15e
Fixed regression related to "converter" field parameter for dataclasses when the converter refers to a generic class constructor. This addresses #7713 .
2024-05-18 14:22:47 -07:00
Eric Traut
7426e71d2c
Changed support for dataclass "converter" field parameter to be off by default. The "enableExperimentalFeatures" must now be enabled to use this feature. If and when PEP 712 is approved, we can move out of experimental.
2024-05-18 14:21:46 -07:00
Eric Traut
017f7c2767
Fixed a bug that results in incorrect type narrowing for a type guard function that uses TypeIs[type[T]]
. This addresses #7946 . ( #7947 )
2024-05-18 00:11:08 -07:00
Eric Traut
7d146aad07
Simplified isinstance code. No functional change.
2024-05-17 23:26:18 -07:00
Eric Traut
7724fce513
Fixed a bug in the code flow engine that results in incorrect type evaluation in certain cases involving codependent variables in a loop. This addresses #7466 . ( #7945 )
2024-05-17 10:09:18 -07:00
Eric Traut
c345c561a0
Changed the handling of Enum
subclasses that explicitly override value
or name
to avoid using the special-case logic for computing these types. This is done regardless of whether the class uses a custom metaclass. This addresses #7939 . ( #7941 )
2024-05-16 21:04:43 -07:00
Eric Traut
7699780a0a
Fixed bug that results in a false negative when determining if a callable type is compatible with another callable type and the first has a *args
parameter and the second has a single positional+keyword parameter. This addresses #7937 . ( #7938 )
2024-05-16 17:44:12 -07:00
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