Commit Graph

6320 Commits

Author SHA1 Message Date
Eric Traut
c767228a82 Improved documentation for "implied else" type narrowing. 2023-06-29 01:28:19 +02:00
PylanceBot
74d8f3c4d2
pull-pylance-with-pyright-1.1.316 (#5401) 2023-06-28 10:35:29 -07:00
Eric Traut
4527c5baa3 Changed '-' command-line feature to support multi-line input. 2023-06-26 22:36:14 +02:00
Eric Traut
85c840c7a5 Fixed a regression that caused a false positive when comparing type compatibility between two Callable types that involve ParamSpecs. This addresses https://github.com/microsoft/pyright/issues/5384. 2023-06-26 22:27:25 +02:00
Eric Traut
67fe93239f Published 1.1.316 2023-06-26 09:02:52 +02:00
Eric Traut
ca370ef2b8
Fixed a bug that led to a false negative when a generic class with called its own constructor using its own type parameters as type arguments. This partially addresses https://github.com/microsoft/pyright/issues/5373. (#5381)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-25 19:41:40 +02:00
Eric Traut
d689dad11e
Moved the evaluation of the first iterator in a comprehension expression out of the comprehension scope to better reflect runtime behavior. (#5379)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-25 09:31:44 +02:00
Eric Traut
ec761d5909 Added isGenerator field to ListComprehensionNode. It's not currently used, but it will likely be useful in the future. 2023-06-25 09:16:02 +02:00
Eric Traut
c286eeca9c Cleaned up some generator test cases. 2023-06-25 08:09:48 +02:00
Eric Traut
9c01bf037b Added a small optimization to code path that assigns classes with type arguments. 2023-06-24 02:41:15 -07:00
Eric Traut
9444c01fb4 Fixed typo in comment. 2023-06-23 07:12:01 -07:00
Eric Traut
195b44e042 Moved decorator functionality out of type evaluator into its own module. 2023-06-22 22:38:22 -07:00
Eric Traut
367b603e42 Renamed a few internal functions for consistency. 2023-06-22 22:23:30 -07:00
Eric Traut
a74a503064
Fixed a bug that results in a false positive error when attempting to assign a class to a Callable type when the class is generic and the constructor includes class-scoped type variables in its parameter annotations. This addresses https://github.com/microsoft/pyright/issues/5369. (#5372)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-22 22:03:46 -07:00
Eric Traut
fbdfb52543 Removed some unnecessary code in the code path for comparing generic class types for type compatibility. 2023-06-22 21:17:36 -07:00
Eric Traut
1340dfac22 Added proper fix for regression that caused crash within certain doubly-nested loops. This addresses https://github.com/microsoft/pyright/issues/5355#issuecomment-1603646306. 2023-06-22 21:16:28 -07:00
Eric Traut
c8a25b2d61 Revert "Added mitigation for reported assertion failure (and crash). This temporarily addresses https://github.com/microsoft/pyright/issues/5355."
This reverts commit 7b242d5e5e.
2023-06-22 21:14:49 -07:00
Eric Traut
241cd62b95 Removed some unnecessary code in the code path that validates generic class type compatibility. 2023-06-22 21:01:49 -07:00
Eric Traut
ea96b47c68
Modified the signature of the synthesized get method for TypedDict classes so it more closely matches the signature (and therefore the behavior) of the get method in dict. This addresses https://github.com/microsoft/pyright/issues/5364. (#5365)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-21 20:44:28 -07:00
Eric Traut
7fb28a4371
Fixed a bug that resulted in a false positive when passing a class to the defaultdict constructor. If an unspecialized class type is used as a upper or lower constraint within the constraint solver, we now use default type arguments (typically Unknown) rather than leaving these type arguments unspecified. This addresses https://github.com/microsoft/pyright/issues/5354. (#5363)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-21 18:53:59 -07:00
Eric Traut
24e755025c Fixed formatting in test case. No functional change. 2023-06-21 16:02:39 -07:00
Eric Traut
b3c77ba45c
Fixed bug that resulted in incorrect type evaluation when a generic callback protocol was invoked in a nested manner. This addresses https://github.com/microsoft/pyright/issues/5356. (#5361)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-21 15:55:50 -07:00
Eric Traut
fb62cc9bf8
Added support for bidirectional type inference when using a dictionary expansion and a dictionary literal expression for an argument corresponding to an unpacked TypedDict **kwargs parameter. This addresses https://github.com/microsoft/pyright/issues/5358. (#5360)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-21 13:53:30 -07:00
PylanceBot
3f84540e0e
pull-pylance-with-pyright-1.1.315 (#5359) 2023-06-21 10:58:59 -07:00
Eric Traut
df7d83c171 Fixed another instance of a false positive reportMissingTypeArgument error when a generic class is passed as the second argument to isinstance. This addresses https://github.com/microsoft/pyright/issues/5294. 2023-06-21 09:52:40 -07:00
Eric Traut
7b242d5e5e Added mitigation for reported assertion failure (and crash). This temporarily addresses https://github.com/microsoft/pyright/issues/5355. 2023-06-21 08:09:40 -07:00
Eric Traut
d4fd3af6d3 Fixed a bug in the new - command-line feature. This addresses https://github.com/microsoft/pyright/issues/5342. 2023-06-20 19:15:24 -07:00
Eric Traut
cef2712bf3 Published 1.1.315 2023-06-20 18:34:15 -07:00
Eric Traut
ed73c0e965
Enhanced the isinstance type narrowing logic so it filters types based on the number of entries in a tuple if the type derives from a tuple. This addresses https://github.com/microsoft/pyright/issues/5346. (#5348)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-20 18:17:06 -07:00
Eric Traut
37535a3171
Fixed a bug that led to incorrect type narrowing for the isinstance type guard in certain cases where the guard type and the pre-narrowed type are both generic. (#5347)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-20 17:45:02 -07:00
Eric Traut
521d84e0cf Added low-level caching mechanism for converting between instance and instantiation types. This should reduce memory usage in some circumstances. 2023-06-20 16:48:02 -07:00
Eric Traut
ca8322f13a Fixed a bug in type caching mechanism that could have resulted in poor performance in certain circumstances. 2023-06-20 16:45:25 -07:00
Erik De Bonte
63f5658ae7
Support PEP 712's new attribute assignment conversion (#5343) 2023-06-20 10:50:18 -07:00
Eric Traut
9cbe8c0841
Fixed a bug that caused an incorrect false positive error for an assert_type call involving a Callable[[], X] type. Pyright was generating a signature with a positional-only separator in this case. This addresses https://github.com/python/typeshed/pull/10325#issuecomment-1598858415. (#5345)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-06-20 09:17:40 -07:00
Eric Traut
d12ad6e2be Updated typeshed stubs to the latest version. 2023-06-19 23:59:08 -07:00
Eric Traut
eff69f5fe5 Fixed a bug that caused incorrect type inference for parameters in unannotated methods within child classes who derive from a generic parent class. This addresses a bug reported on stack overflow: https://stackoverflow.com/questions/76466874/trouble-specifying-type-parameter-when-inheriting-from-generic-class. 2023-06-19 22:35:56 -07:00
Eric Traut
43c5fae1a1 Finished cleanup of test cases. 2023-06-19 20:17:00 -07:00
Eric Traut
b0d4080c36 Next batch of test case cleanup. 2023-06-19 19:15:53 -07:00
Eric Traut
efea9b993c Changed behavior of non-ClassVar variables within a protocol definition. Previously, an error was reported when such variables were accessed from the class (as opposed to an instance of the class). Mypy (which was the reference implementation for PEP 544) does not report an error here. This addresses https://github.com/microsoft/pylance-release/issues/4389. 2023-06-19 18:26:49 -07:00
Eric Traut
5568b4dc95 Enhanced command-line version of pyright to allow file or directory names to be passed via stdin if - option is used in the command line. This addresses https://github.com/microsoft/pyright/issues/5342. 2023-06-19 18:00:31 -07:00
Eric Traut
cd257f722e Next batch of test case cleanup. 2023-06-19 15:38:13 -07:00
Eric Traut
0c5c7b65ef Next batch of text case cleanup. 2023-06-19 14:23:50 -07:00
Eric Traut
899799dcf7 Finished cleaning up "genericTypesX.py" test files. 2023-06-19 13:33:41 -07:00
Eric Traut
1111f1b9bb Started to untangle the hairball related to the "genericTypesX.py" test cases. 2023-06-19 11:49:56 -07:00
Eric Traut
67394ad67c Continued cleanup of test cases. 2023-06-19 10:21:36 -07:00
Eric Traut
96e03aaad1 Did a cleanup pass for the dataclass test cases. Renamed and reordered test cases for maintainability. 2023-06-19 09:39:09 -07:00
Eric Traut
b7df20097a Fixed bug that resulted in a false positive error when defining a new type alias using the TypeAliasType constructor that defines no new type parameters but references an outer-scoped type parameter in the type alias definition. This addresses https://github.com/microsoft/pyright/issues/5341. 2023-06-19 08:20:54 -07:00
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