Commit Graph

6373 Commits

Author SHA1 Message Date
Eric Traut
d816d0041c Started to do a pass over the test cases to make them more consistent. 2023-06-19 00:00:07 -07:00
Eric Traut
23bcbcebfb Fixed bug in code flow engine that led to incorrect type evaluation of a variable in a nested loop. This addresses https://github.com/microsoft/pylance-release/issues/4509. 2023-06-18 17:42:25 -07:00
Eric Traut
056415f6f4 Fixed a bug in the control flow debugging code that prints the control flow graph. It was not correctly handling one of the node types which led to incomplete graphs. 2023-06-18 16:40:00 -07:00
Eric Traut
643bb1d133
Improved type inference for lambdas in the case where a parameter includes a default value and the expected type doesn't include that parameter. This improvement was suggested in the [mypy issue tracker](https://github.com/python/mypy/issues/15459). (#5337)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-18 13:20:49 -07:00
Eric Traut
8ce23eb615
Improved reportUnnecessaryCast so it works with types other than cl… (#5336)
Improved `reportUnnecessaryCast` so it works with types other than class instances. This addresses https://github.com/microsoft/pyright/issues/5333.
2023-06-18 12:55:22 -07:00
Eric Traut
52c8cac1ff Changed type printer (the component that renders types into text) to use the lowercase type[x] instead of Type[x]. It has now been four years since PEP 585 deprecated the use of the upper-case version, so most developers should be getting comfortable with the lowercase version at this point. 2023-06-18 12:41:24 -07:00
Eric Traut
e3080b1369
Fixed a bug that led to a false positive error under certain circumstances when a literal type argument was used in conjunction with a protocol that used a covariant type parameter and an implementation of that protocol that used an invariant type parameter. This addresses https://github.com/microsoft/pyright/issues/5282. (#5332)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-18 10:15:58 -07:00
Eric Traut
2b0f8d22cd Improved hover text to display the calculated variance for a PEP 695-style class-scoped type variable when the user hovers over the type parameter in the type param list. 2023-06-18 09:46:18 -07:00
Eric Traut
02b7769198
Fixed a false positive error arising from the use of a binary expression for a base class in a class declaration statement. This addresses https://github.com/microsoft/pyright/pull/5326. (#5331)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-18 00:17:53 -07:00
Eric Traut
2de35e3684 Added documentation about higher-order functions. 2023-06-18 00:00:06 -07:00
Eric Traut
42a37f4b98 Re-enabled a test case that was previously disabled because it was broken. 2023-06-17 23:38:50 -07:00
Eric Traut
7ea11a1866 Minor code cleanup — rename constant for clarity and refactor validation function. No functional change. 2023-06-17 23:17:32 -07:00
Eric Traut
53cb3f92dd Improved consistency of parameter ordering internally to type evaluator. No functional change. 2023-06-17 23:00:49 -07:00
Eric Traut
9bf823160c
Fixed a bug that led to incorrect type evaluation when passing a generic class (with a constructor that includes class-scoped TypeVars) as an argument for a callable parameter. The class was being specialized prematurely (with type arguments set to Unknown) before the constraint solver was able to solve the higher-order function's type variables. This addresses https://github.com/microsoft/pyright/issues/5324. (#5328)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-17 22:48:18 -07:00
Eric Traut
47cd514dbd
Changed auto-variance algorithm to ignore __new__ and __init__ methods for purposes of calculating the variance of a TypeVar. This mirrors the behavior of mypy. (#5327)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-17 22:21:52 -07:00
Eric Traut
3021b9c621 Minor code cleanup — removed dead code and converted lambda to function. No functional change. 2023-06-17 21:52:57 -07:00
Eric Traut
327ce37701 Added test case for https://github.com/microsoft/pyright/issues/5027. 2023-06-17 20:30:36 -07:00
Eric Traut
05593825a2
Fixed false negative when a literal and non-literal are assigned to the same TypeVar in an invariant context. This addresses https://github.com/microsoft/pyright/issues/5321. (#5323)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-17 14:19:12 -07:00
Eric Traut
2829429742
Fixed bug that led to an incorrect type evaluation for nested call expressions where an inner call expression used a ParamSpec. This addresses https://github.com/microsoft/pyright/issues/5281. (#5322)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-17 12:33:13 -07:00
Eric Traut
b90abab417
Improved the heuristic used to determine which subtypes of a union within an "expected type" should be used for bidirectional type inference. This addresses https://github.com/microsoft/pyright/issues/5312. (#5317)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-16 00:43:11 -07:00
Eric Traut
2cd0220207
Fixed several subtle bugs in the overload matching algorithm in the case where Any or Unknown arguments are present. (#5316)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-15 20:48:54 -07:00
Eric Traut
8a09073e6e
Fixed a false negative where an unpacked dictionary argument was not validated against the **kwargs parameter type. This addresses https://github.com/microsoft/pyright/issues/5309. (#5310)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-15 16:01:25 -07:00
Eric Traut
8d9910eb89 Added more details about difference between mypy and pyright overload resolution in ambiguous cases. 2023-06-15 16:01:12 -07:00
Eric Traut
450f71bf1c Fixed a regression that caused an incorrect type evaluation of a function that returns a callable with a ParamSpec that does not appear outside of the return type annotation. A previous fix didn't correctly handle the case that involved a class parameterized with a ParamSpec. This addresses https://github.com/microsoft/pyright/issues/5283. 2023-06-15 12:35:12 -07:00
Eric Traut
20ce6049f3 Changed parameter type inference logic to avoid inferring the type of an unannotated parameter with a default value consisting of a lambda. This addresses https://github.com/microsoft/pyright/issues/5306. 2023-06-15 11:53:12 -07:00
Eric Traut
5c725bc267 Fixed a bug that led to a false positive when passing unpacked lists or dictionaries to a constructor for a class that doesn't provide its own constructor and falls back to the object constructor. 2023-06-15 09:23:39 -07:00
Ross J. Duff, MSc
b12ca05927
Clarification of --version argument usage string (#5308)
* Update command-line.md

clarify that `--version` prints the version *and exits*

* Update --version usage string

Clarifies that `--version` prints the version *and exits*, this is fairly common language used by most CLI apps to indicate what the behavior of `--version` is. It may surprise new users that `--version` exits rather than appending the version with the previous language.
2023-06-15 08:42:26 -07:00
Eric Traut
d1c482b143
Fixed bug that led to false positive errors when (#5305)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-14 19:28:53 -07:00
Eric Traut
f97ca0546c
Fixed a bug in type evaluation of the two-argument form of the super call. There were situations where the incorrect MRO class was used. This addresses https://github.com/microsoft/pyright/issues/5299. (#5304)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-14 17:44:55 -07:00
Eric Traut
6de44b9237 Changed mypy_primer PR script to use 2 shards (parallel action executions) rather than 1 to reduce wait times. 2023-06-14 17:36:01 -07:00
Eric Traut
b0c4716f7b
Fixed a bug that leads to a false positive error in the reportIncompatibleMethodOverride check when a child class is overriding an overloaded method in the base class and one or more of the overloads doesn't apply because the self or cls parameter is explicitly annotated in a way that's not applicable to the child class. This addresses https://github.com/microsoft/pyright/issues/5288. (#5302)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-14 15:52:11 -07:00
Eric Traut
7bfe3153ce
Modified protocol matching and the constraint solver to handle an edge case where a partially-solved type variable with a solution of Any are provided by other argument types in a call. This addresses https://github.com/microsoft/pyright/issues/5243. (#5296)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-14 12:24:35 -07:00
Eric Traut
4d27f864b2
Fixed a regression that caused a false positive reportMissingTypeArgument diagnostic when using a generic type in conjunction with the | union operator in the second argument to an isinstance or issubclass call. This addresses https://github.com/microsoft/pyright/issues/5294. (#5295)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-14 11:00:55 -07:00
PylanceBot
ae795f5b8e
pull-pylance-with-pyright-1.1.314 (#5293) 2023-06-14 10:09:58 -07:00
Eric Traut
0b49479dff Published 1.1.314 2023-06-13 20:21:13 -07:00
Eric Traut
f7b3a1dd7f
Fixed a regression that caused an incorrect type evaluation of a function that returns a callable with a ParamSpec that does not appear outside of the return type annotation. This addresses https://github.com/microsoft/pyright/issues/5283. (#5284)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-13 14:27:15 -07:00
Eric Traut
b0c108f236 Updated issue templates. 2023-06-12 15:43:24 -07:00
Eric Traut
810f37f5fd
Fixed a bug that led to a false positive reportIncompatibleMethodOverride error for overloaded method overrides in cases where the overloads are differentiated based on explicit types for the self or cls parameter. This addresses https://github.com/microsoft/pyright/discussions/5275. (#5279)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-12 14:18:29 -07:00
Eric Traut
76f2dd1384
Fixed a bug that led to infinite analysis time and heap exhaustion when analyzing an overloaded function that includes a ParamSpec that uses itself as an argument. This addresses https://github.com/microsoft/pyright/issues/5163. (#5276)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-12 13:36:20 -07:00
Eric Traut
d20a39cef3
Typeshed update 2 (#5274)
* Improved the protocol matching logic so it honors partially-solved type variables whose values are provided by other argument types in a call. This addresses https://github.com/microsoft/pyright/issues/5243.

* Updated typeshed to the latest version.

---------

Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-12 08:42:55 -07:00
Eric Traut
7ffe61abc1
Improved the protocol matching logic so it honors partially-solved type variables whose values are provided by other argument types in a call. This addresses https://github.com/microsoft/pyright/issues/5243. (#5273)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-12 08:40:51 -07:00
Eric Traut
783633a260
Cleaned up code in protocols module in prep for a significant change required to fix https://github.com/microsoft/pyright/issues/5243. (#5272)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-12 08:21:10 -07:00
Eric Traut
3931cf6431
Simplified buildTypeVarContextFromSpecializedClass utility function in preparation for further changes. (#5269)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-11 19:52:24 -07:00
Eric Traut
f018ebdd29 Fixed false positive error when using a *args: P.args as the first parameter in a method. 2023-06-11 08:19:30 -07:00
Eric Traut
d5856e38a0 Reverted the use of the TypeWalker for the isPartlyUnknown function. This function is called very frequently, and allocating a new walker object every time it's called is too expensive. This addresses https://github.com/microsoft/pyright/issues/5245. 2023-06-09 19:03:32 -06:00
Eric Traut
c7f3b8d9fd
Fixed a bug that led to a false negative when passing an unpacked tuple of length one to a function that requires more (or fewer) than one positional argument. This addresses https://github.com/microsoft/pyright/issues/5261. (#5263)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-09 17:34:13 -06:00
Eric Traut
639717217d
Fixed bug that resulted in a false negative when using the reportMissingTypeArgument check when defining an old-style type alias. This same bug resulted in inconsistent behavior between Union and |, which should be equivalent. This addresses https://github.com/microsoft/pyright/issues/5256. (#5262)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-09 17:02:27 -06:00
Serhii Tereshchenko
0d0e716f92
Update ci-integration.md (#5259)
When both scripts are executed in `scripts:` section, and `pyright` reports error, second script is not executed.

Best way to ensure report are always converted, is to use `after_script:` block.
2023-06-09 08:37:45 -06:00
Eric Traut
dc9413ce71 Fixed style issue. 2023-06-08 23:23:47 -06:00
Eric Traut
71f0f77afc Added comments to new workflow definition files. 2023-06-08 23:09:15 -06:00