Eric Traut
2b0a1d92dd
Simplified FunctionType.cloneForSpecialization method.
2024-06-10 19:39:33 -07:00
Eric Traut
ec196107e2
Updated typeshed stubs to the latest version (to pick up recent fix in shutil.pyi
).
2024-06-10 13:40:05 -07:00
Eric Traut
81d43e4c41
Added consistent use of getTypeVarScopeId
accessor function. No functional change.
2024-06-10 13:37:17 -07:00
Eric Traut
45fcebfe2c
Changed the import resolution order to better reflect runtime behavior and match a proposed change to the typing spec. In particular, stdlib typeshed stubs are now resolved prior to site_packages
. This addresses #8099 . ( #8100 )
2024-06-09 07:57:44 -07:00
Eric Traut
e588c6f984
Fixed bug in previous commit the caused default include/exclude values not to be provided in the case where a pyproject.toml was present but contained no pyright section. Thanks to @augustelalande for catching this.
2024-06-08 23:06:00 -07:00
Eric Traut
4319e03b71
Fixed bug that led to divergent behaviors between pyrightconfig.json and pyproject.toml configurations. Specifically, default exclude patterns were not added in the case of pyproject.toml. This addresses #8102 .
2024-06-08 22:24:45 -07:00
Eric Traut
238f70049f
Fixed bug that results in a false positive error under certain circumstances involving tuple type narrowing in a loop. This addresses #8095 . ( #8098 )
2024-06-08 13:12:36 -07:00
Eric Traut
5a0ec2dda4
Fixed bug that causes Final
annotation not to be honored when wrapped in an Annotated
annotation. This addresses #8097 .
2024-06-08 10:10:38 -07:00
Eric Traut
ec229aa925
Fixed a bug that results in incorrect (local) type evaluation of an instance variable with a declared type when assigned within a loop that uses an augmented assignment. This addresses #8090 . ( #8093 )
2024-06-07 15:51:02 -07:00
Eric Traut
aad860332e
Fixed bug that results in duplicate and (contradictory) diagnostic outputs in certain cases where reveal_type
is used in a loop.
2024-06-07 14:36:54 -07:00
Eric Traut
a0af8c5c8c
Simplified interface to "assignTypeToXXX" methods.
2024-06-07 14:02:05 -07:00
Eric Traut
4b84651950
Added the ability to override type checking configuration settings for each execution environment. This allows, for example, a test directory to use different settings than the directories that contain production code. This addresses #4059 .
2024-06-06 15:25:01 -07:00
Eric Traut
2c313972d3
Simplified JSON schema for config file in advance of adding config overrides for execution contexts.
2024-06-06 15:08:29 -07:00
Eric Traut
a4873a6a83
Simplified some code for logging diagnostics in checker and binder.
2024-06-06 13:57:48 -07:00
Eric Traut
32076952c7
Fixed bug that results in a false positive when accessing a generic attribute in a base class from a subclass that explicitly specializes the generic type. This addresses #8083 . ( #8086 )
2024-06-06 10:29:53 -07:00
Eric Traut
a029774b99
Added extra blank line to JSON output to assist with parsing when used in watch mode. This addresses #8082 .
2024-06-06 08:49:04 -07:00
Eric Traut
16ea2a80c5
Added check for except*
to enforce that exception class does not derive from BaseExceptionGroup
.
2024-06-05 22:57:21 -07:00
Eric Traut
2ade792ba8
Did a small cleanup pass on the implementation of PEP 746.
2024-06-05 21:00:48 -07:00
Eric Traut
ac7f6b7f74
Implemented provisional support for PEP 746, which provides consistency checks for metadata used in an Annotated
annotation.
2024-06-05 20:24:36 -07:00
Eric Traut
7c5495c1b4
Renamed some internal functions and constants for consistency and clarity.
2024-06-05 18:41:08 -07:00
Eric Traut
e2adef6b88
Updated typeshed stubs to the latest version. This addresses #8079 .
2024-06-05 18:13:08 -07:00
Eric Traut
de8e9939d2
Simplified logic and data structures for functions with parameter specs. ( #8080 )
2024-06-05 17:11:42 -07:00
PylanceBot
5551c4ac4e
pull-pylance-with-pyright-1.1.366-9378053462 ( #8072 )
...
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rich Chiodo <rchiodo@users.noreply.github.com>
2024-06-05 10:05:53 -07:00
Eric Traut
8fa827608d
Fixed bug that results in incorrect truthy/falsy type narrowing for an enum that overrides __bool__
. This addresses #8074 .
2024-06-05 08:56:31 -07:00
Eric Traut
cff7779bdb
Published 1.1.366
2024-06-04 21:05:01 -07:00
Eric Traut
e90e041380
Added diagnostic check for an enum member with a type annotation. The typing spec says that this should be considered a typing error. This addresses #8060 . ( #8069 )
2024-06-04 11:11:06 -07:00
Eric Traut
58094a5c4e
Changed behavior of pyright to match the latest typing spec when it encounters an attribute with a type annotation within an Enum
class body in a stub. These are now treated as non-member attributes rather than members. Typeshed stubs have been updated to conform to the new standard. This addresses #8061 . ( #8063 )
2024-06-03 17:24:07 -07:00
Eric Traut
46eba6ab41
Fixed bug in x is E
type narrowing pattern where E
is an enum literal and x
is a supertype of E
like object
. This addresses #8059 . ( #8062 )
2024-06-03 17:08:32 -07:00
Eric Traut
14a7622300
Fixed several misspellings in the code base. No functional change.
2024-06-03 13:34:37 -07:00
Eric Traut
e3ce2c8033
Updated typeshed stubs to the latest version.
2024-06-03 11:59:39 -07:00
Eric Traut
67fd972213
Issue8054 ( #8055 )
...
* Fixed bug that results in a false negative when solving a type variable that involves an invariant context.
* Fixed a bug that can result in incorrect type inference for a subexpression that is part of an assignment expression if executed with an inference context (bidirectional type inference). This addresses #8054 .
2024-06-03 11:24:06 -07:00
Eric Traut
5ac25c8256
Fixed bug that results in a false negative when solving a type variable that involves an invariant context. ( #8051 )
2024-06-02 22:37:52 -07:00
Eric Traut
e4226ffea9
Revert "Simplified code in the typeVarContext module."
...
This reverts commit a572c05b26
.
2024-06-02 22:04:29 -07:00
Eric Traut
ac7f66131a
Revert "Restructure code in constraint solver. No functional change."
...
This reverts commit 6609e93ee6
.
2024-06-02 22:04:17 -07:00
Eric Traut
6609e93ee6
Restructure code in constraint solver. No functional change.
2024-06-02 21:25:55 -07:00
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