Commit Graph

6373 Commits

Author SHA1 Message Date
Eric Traut
6a43d966de Fixed a bug that led to an unsolved type variable within a union producing an Unknown type in some cases. This triggers false positive errors in strict mode. This addresses https://github.com/microsoft/pyright/issues/5183. 2023-05-27 13:52:32 -06:00
Eric Traut
59f8f38cfc Fixed a recent regression that resulted in the incorrect evaluation of the value field for an Enum. This addresses https://github.com/microsoft/pyright/issues/5187. 2023-05-27 09:20:44 -06:00
Eric Traut
e102fe755c Fixed a recent regression that affected a function that returned a generic Callable that used type[T] rather than T in the type annotation. This addresses https://github.com/microsoft/pyright/issues/5188. 2023-05-27 08:49:40 -06:00
Eric Traut
6e6c3664b3 Added documentation for pyright's handling of constructor calls and how this differs from mypy. 2023-05-25 18:36:11 -07:00
Eric Traut
ebf474432a Fixed a bug that led to (temporary) sporadic reportUnnecessaryTypeIgnoreComment errors. This addresses https://github.com/microsoft/pyright/issues/5179. 2023-05-25 14:08:36 -07:00
Eric Traut
344ba99d58 Fixed recent regression that led to a false negative when using functools.partial with bidirectional type inference. This addresses https://github.com/microsoft/pyright/issues/5164. 2023-05-24 21:35:10 -07:00
Eric Traut
d7fe43bfbf Updated bug template to clarify that we're looking for a minimal, self-contained code sample in text form. 2023-05-24 20:19:55 -07:00
Eric Traut
87abc03f65 Made TextRange (and range fields in ParseNodeBase) immutable. A couple of recent bugs would have been avoided with this. 2023-05-24 19:06:38 -07:00
Eric Traut
16e2a8cda4 Fixed a bug that resulted in a crash in certain cases within the argument/parameter matching logic. This addresses https://github.com/microsoft/pyright/issues/5173. 2023-05-24 14:45:12 -07:00
PylanceBot
0d24883416
pull-pylance-with-pyright-1.1.310 (#5171) 2023-05-24 10:02:39 -07:00
Eric Traut
91a2ec2c2c Fixed regression in f-string tokenization that led to a false positive error when an escape character (backslash) is used with a carriage return or line feed within the non-expression part of an f-string. This addresses https://github.com/microsoft/pyright/issues/5167. 2023-05-24 08:49:21 -07:00
Eric Traut
7e95fe8d9e Published 1.1.310 2023-05-23 17:06:23 -07:00
Eric Traut
d2322ad605 Fixed a bug that caused an internal cache to be corrupted leading to a false positive error in specific circumstances. This addresses https://github.com/microsoft/pyright/issues/5159. 2023-05-23 16:09:04 -07:00
Eric Traut
f50393d9ea Modified constraint solver to limit the number of subtypes in a union for the narrow bound of a type variable. Under certain rare circumstances, this can grow to a very large number and cause perf issues and hangs. This addresses https://github.com/microsoft/pyright/issues/5162. 2023-05-23 15:09:53 -07:00
Eric Traut
0685e2771a Added perf optimization to stripLiteralValue method to handle large unions comprised only of literal values. 2023-05-23 15:07:55 -07:00
Eric Traut
5779fe1605 Addressed a performance issue that occurs when analyzing complex functions with deeply nested lambdas. This change adds a more sophisticated type caching mechanism that avoids emptying the cache when analyzing lambdas. This addresses https://github.com/microsoft/pyright/issues/4950. 2023-05-22 23:38:24 -07:00
Eric Traut
146156c5cc Fixed bug that led to the incorrect type evaluation of an async generator when an await operator was used within a nested expression. This addresses https://github.com/microsoft/pyright/issues/2322. 2023-05-22 13:47:14 -07:00
Eric Traut
50260659c3 Fixed a couple of bugs in the method override consistency check that resulted in false positives when ParamSpecs were involved. This addresses https://github.com/microsoft/pyright/issues/5151. 2023-05-22 13:15:10 -07:00
Eric Traut
dd109eb9ce Renamed ParameterCategory enumeration for clarity and brevity. Added new accessor functions for position-only and keyword-only separators. No functional change. 2023-05-22 13:04:38 -07:00
Christina Hanson
a428fe81be
Preserve parentheses around unary operators for printing (#5152) 2023-05-22 13:00:30 -07:00
Eric Traut
d91130c189 Fixed bug that resulted in a false positive error when the "expected type" for a lambda is a function that includes a ParamSpec. This addresses https://github.com/microsoft/pyright/issues/5147. 2023-05-21 21:38:00 -07:00
Eric Traut
130f5fa893 Minor code simplification in lambda inference code. No functional change. 2023-05-21 21:24:47 -07:00
Eric Traut
adb0e577ca Updated typeshed stubs to the latest version. 2023-05-21 19:01:35 -07:00
Eric Traut
ec36e38ff7 Fixed recent regression that caused useLibraryCodeForTypes setting not to be applied if it was specified in the language server settings (as opposed to the config file). 2023-05-21 13:46:03 -07:00
Eric Traut
0998a3a7a4 Changed the behavior when a parameter whose type is a "naked" TypeVar has a default argument value. Mypy doesn't allow this case. Pyright allows it but previously modified the parameter type to be a union of the TypeVar and the type of the default argument. This behavior closed some type validation holes, but it created other problems and was very unintuitive for users. See https://github.com/microsoft/pyright/issues/3130. See https://github.com/microsoft/pyright/issues/2507 for a discussion that led to this original change. This change reverses this behavior. It potentially allows for some unsafe "creative" uses that will go unreported. 2023-05-21 12:46:10 -07:00
Eric Traut
7cdcef144d Fixed a bug that led to a false positive error in certain circumstances with nested call expressions where the expected type of the parameter was a union. This addresses https://github.com/microsoft/pyright/issues/5065. 2023-05-21 12:24:48 -07:00
Eric Traut
c8da3a3c93 Changed type narrowing on assignment for member access expressions that involve an asymmetric __getattr__ and __setattr__ method. As with asymmetric descriptors, it is not safe in this case to assume that the written value will be the same as the read value. This addresses https://github.com/microsoft/pyright/issues/5121. 2023-05-20 15:34:13 -07:00
Eric Traut
ca6fdaf04e Changed protocol matching behavior for protocols that include a variable annotated as ClassVar. A class that defines this same variable as a "regular class variable" (one that is declared at the class level but can be overwritten on a per-instance basis) is now considered compatible with such a protocol. This addresses https://github.com/microsoft/pylance-release/issues/4389. 2023-05-20 12:27:36 -07:00
Eric Traut
425d940452 Added comment. No functional change. 2023-05-20 12:14:24 -07:00
Eric Traut
b29ba66e82 Added minor optimization to previous commit. 2023-05-20 00:29:13 -07:00
Eric Traut
25aaefe77f Added special-case synthesis of the update method for a TypedDict class. For TypedDicts that include at least one read-only field, no updates are allowed. For TypedDicts that are writable, a "partial" type is synthesized that allows for any subset of keys (required or not required) to be passed to the update method. This addresses https://github.com/microsoft/pyright/discussions/5141. 2023-05-19 23:58:46 -07:00
Eric Traut
0a85467eff
Implemented ReadOnly TypedDict fields to explore proposed PEP 705 variant. This is related to https://github.com/microsoft/pyright/issues/5118. (#5132)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-05-19 18:20:04 -07:00
Eric Traut
c2bf866d41 Fixed style issue. 2023-05-19 17:31:27 -07:00
Erik De Bonte
b971a0c689
Add PEP 712 to features.md (#5143) 2023-05-19 17:07:39 -07:00
Eric Traut
4ee51512ee Reimplemented handling of f-strings in accordance with PEP 701, which is slated for inclusion in Python 3.12. This is a significant change with potential for regressions. This addresses https://github.com/microsoft/pyright/issues/5124. 2023-05-19 17:05:47 -07:00
Erik De Bonte
676eba9ec4
TextRange.combine should not modify input ranges (#5142) 2023-05-19 12:55:37 -07:00
Eric Traut
fedcafb706 Fixed a bunch of places in the pyright code where lists were being expanded on the stack, potentially resulting in a stack overflow. This addresses https://github.com/microsoft/pyright/issues/5139. 2023-05-18 17:18:20 -07:00
Eric Traut
73ce0d435f Fixed a false positive error with the reportImplicitOverride check that occurs when the @override decorator is applied to a method that is decorated with a wrapper function that completely replaces the original function with another. This addresses https://github.com/microsoft/pyright/issues/5133. 2023-05-17 21:18:11 -07:00
Eric Traut
14655ce6c2 Code prep for PEP 705 implementation. 2023-05-17 17:23:35 -07:00
Eric Traut
723df6f7ba Deleted unused private functions in binder. 2023-05-17 14:51:30 -07:00
Eric Traut
aa471a2591 A class created with "NewType" should be treated as though it is implicitly @final. The runtime enforces this. Pyright now correctly generates an error if such a class is used as a base class. This addresses https://github.com/microsoft/pyright/issues/5127. 2023-05-17 14:35:30 -07:00
Eric Traut
bc8cca28ba Fixed bug that led to a "leaked" unsolved type variable if a __new__ method used a function-scoped type variable and there was no __init__ method for the class. This addresses https://github.com/microsoft/pyright/issues/5126. 2023-05-17 14:22:17 -07:00
Rich Chiodo
e6d7b84c80
Push pylance changes to pyright (#5131)
* Push pylance changes to pyright

* Fixup merge problems

* Update packages/pyright-internal/src/analyzer/backgroundAnalysisProgram.ts

Co-authored-by: Erik De Bonte <erikd@microsoft.com>

---------

Co-authored-by: Erik De Bonte <erikd@microsoft.com>
2023-05-17 10:43:31 -07:00
Eric Traut
6f87c5ddbf Fixed regression that caused an internal assertion (and therefore a crash) when type checking a constructor whose arguments are not type compatible. This addresses https://github.com/microsoft/pyright/issues/5129. 2023-05-17 09:48:04 -07:00
Eric Traut
27d495afc6 Published 1.1.309 2023-05-16 20:53:04 -07:00
Eric Traut
c04ee3fe7d Revert "Fixed a bug that led to a false positive error in certain circumstances with nested call expressions where the expected type of the parameter was a union. This addresses https://github.com/microsoft/pyright/issues/5065."
This reverts commit 674465ef53.
2023-05-16 20:51:11 -07:00
Eric Traut
571078a774 Updated bug template to direct people to the discussion forum for questions. 2023-05-16 09:03:36 -07:00
Eric Traut
35a2ed939c Updated features documentation to mark PEP 695 as no longer in draft form. 2023-05-15 23:16:36 -07:00
Eric Traut
d08edd1911 Changed pyright to reflect a recent decision about PEP 649 (deferred type annotations). The steering council tentatively approved PEP 649 for Python 3.12, but they recently decided to defer it until 3.13. 2023-05-15 18:41:39 -07:00
Eric Traut
674465ef53 Fixed a bug that led to a false positive error in certain circumstances with nested call expressions where the expected type of the parameter was a union. This addresses https://github.com/microsoft/pyright/issues/5065. 2023-05-15 18:36:51 -07:00