Commit Graph

5022 Commits

Author SHA1 Message Date
Eric Traut
a572c05b26 Simplified code in the typeVarContext module. 2024-06-02 19:34:03 -07:00
Eric Traut
409df8ff72
Fixed bug that results in false positive when evaluating the call to a generic function that involves a type variable used in both a covariant and contravariant (or invariant) position and both literal and non-literal types are involved. This addresses part of #6207. (#8049) 2024-06-02 14:19:13 -07:00
Eric Traut
ecc4ebb12a Fixed bug that results in a confusing error message when stub generation fails. This addresses #8044. 2024-06-01 11:29:00 -07:00
Eric Traut
c7fbc82337 Reversed the change for #8035. Tuple expressions used in generators will not retain literal types. 2024-05-31 20:45:50 -07:00
Eric Traut
5dba796e16 Minor code cleanup in program module. 2024-05-31 19:57:59 -07:00
Eric Traut
8a2857876b Renamed references to "list comprehension" to "comprehension" in various places for clarity. Comprehensions can be used in lists, dicts, sets or none of the above (in which case it's interpreted as a generator). 2024-05-31 17:57:40 -07:00
Eric Traut
03ddb0917b
Changed the tuple inference behavior to retain literals (as it did prior to 1.1.365) when a tuple expression is used within a generator expression. This addresses #8035. (#8036) 2024-05-31 17:37:06 -07:00
Eric Traut
e69974cee0 Fixed bug that results in a false positive error under certain circumstances involving a call to a higher-order generic function with another function that involves a class with a contravariant type variable. This addresses #7212. 2024-05-31 13:44:51 -07:00
Eric Traut
0e42a7ea56 Removed support for inlined TypedDict annotations. This idea never gained enough support to make it into a PEP. 2024-05-30 18:16:13 -07:00
Eric Traut
1bc5949959 Added comments for experimental features. 2024-05-30 18:14:47 -07:00
Eric Traut
181382d6a1 More cleanup of prefetched types. 2024-05-30 18:08:46 -07:00
Eric Traut
ce229098e6 Code cleanup for prefetched types used in type evaluator. 2024-05-30 17:41:39 -07:00
Eric Traut
32fa85e3ed
Changed behavior of constructor call evaluation when __new__ evaluation results in type evaluation errors. Previously, pyright skipped the __init__ evaluation in this case. It now proceeds to evaluate __init__, potentially generating redundant errors. This addresses #8026. (#8029) 2024-05-30 12:49:11 -07:00
PylanceBot
2e397e9a0a
[PylanceBot] Pull Pylance with Pyright 1.1.365 (#8016)
* pull-pylance-with-pyright-1.1.365-9280185292

* Update package.nls.ko.json typo

Fix typo

---------

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-29 09:49:41 -07:00
Eric Traut
66101ee0c5 Published 1.1.365 2024-05-28 21:12:35 -07:00
Eric Traut
ece525e960
Fixed bug that results in a false negative when a Final class variable is assigned a value in the class body and reassigned a value in the __init__ method. This addresses #8013. (#8015) 2024-05-28 20:42:09 -07:00
Eric Traut
59eabcb60f
Fixed bug that leads to inconsistent narrowing-on-assignment behavior when a tuple instance with unknown type arguments is assigned to a target symbol with a declared tuple type. This addresses #8001. (#8005) 2024-05-26 23:42:37 -07:00
Eric Traut
a4d165ec02 Fixed regular expression for # type: ignore and # pyright: ignore comments. This addresses #8000. 2024-05-25 09:30:05 -07:00
Eric Traut
c1b5bccca0 Did some internal refactoring in preparation for implementation of new functionality. No functional change. 2024-05-25 00:33:38 -07:00
Eric Traut
1bba737d93
Fixed a bug that results in an unsolved TypeVar when calling list(tuple()). This addresses #7998. (#7999) 2024-05-25 00:25:05 -07:00
Eric Traut
1466ccb653 Fixed issue with chained config files related to typeCheckingMode. 2024-05-24 18:01:20 -07:00
Eric Traut
421dabee57
Added support for configuration inheritance through an "extends" configuration option. This addresses #4366. (#7997) 2024-05-24 17:22:12 -07:00
Eric Traut
0a83d6459c
Fixed a bug that results in incorrect type compatibility checks for a… (#7994)
* Fixed a bug that results in incorrect type compatibility checks for a callable that uses `*args: *tuple[T, *tuple[S, ...]]`. This addresses #7987.

* Improved diagnostic messages for parameter mismatch.
2024-05-24 13:19:16 -07:00
Eric Traut
af916c6644 First step in improving code for parameter matching for callable assignments. This step involves simple renaming. No functional change. 2024-05-24 10:10:16 -07:00
Eric Traut
a1ac859982 Small cleanup in callback protocol test. 2024-05-24 10:09:14 -07:00
Eric Traut
aed4c75980 Fixed regression that results in the incorrect type evaluation for the value attribute of a StrEnum or IntEnum class. This addresses #7983. 2024-05-23 09:18:30 -07:00
Ujan RoyBandyopadhyay
bfc60526a0
Use typeshed version info for stdlib module list (#7982) 2024-05-23 09:04:55 -07:00
Eric Traut
50d4f44735
Changed tuple expression inference behavior to not preserve literal entry types if the tuple expression is embedded within another tuple, set, list, or dictionary expression. This addresses #7159. (#7970) 2024-05-22 16:10:05 -07:00
Bill Schnurr
0618acc535
pylance-22-5-2024 -> pyright (#7980)
* pullpylance-22-5-2024

  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-05-22 15:34:30 -07:00
Eric Traut
a18387f1c4 Published 1.1.364 2024-05-21 19:04:30 -07:00
Eric Traut
4a8b2dbbdd Removed unused import in test. 2024-05-21 16:45:54 -07:00
Eric Traut
b93dc627fc Added small memory and performance optimization. 2024-05-21 13:00:33 -07:00
Eric Traut
be320a8b08
Added support for using Literal and various other special forms in a value expression. This addresses #7547. (#7969) 2024-05-21 12:20:01 -07:00
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