Commit Graph

6093 Commits

Author SHA1 Message Date
Eric Traut
0c308e057f Published 1.1.307 2023-05-09 22:30:57 -07:00
Eric Traut
c89ffb7392 Made "Pyproject file has no pyright section" log message an "Info" message rather than an error to reduce noise. 2023-05-09 22:30:45 -07:00
Eric Traut
cdbee5bd6e Improved handling of NewType when Any is passed as a second argument. This addresses https://github.com/microsoft/pyright/issues/5084. 2023-05-09 19:35:40 -07:00
Eric Traut
a2ca488fd2 Renamed and restructured some code in preparation for a larger change. No functional change. 2023-05-09 18:57:36 -07:00
Eric Traut
0108e5d971 Eliminated circular dependency between typeUtils and typeVarContext modules. No functional change. 2023-05-09 18:50:18 -07:00
Eric Traut
6a51ea311f Added debugging routine for printing TypeVarContext. 2023-05-09 18:05:57 -07:00
Eric Traut
06392e2587 Fixed bug that caused any function or method named deprecated to be treated as though it behaved like typing.deprecated (introduced in PEP 702). This addresses https://github.com/microsoft/pyright/issues/5082. 2023-05-09 08:27:05 -07:00
Eric Traut
e1740cff9a Fixed a bug that resulted in a false positive error when binding a classmethod within a metaclass (i.e. a subclass of type). This addresses https://github.com/microsoft/pyright/issues/5079. 2023-05-08 09:46:21 -07:00
Eric Traut
abb4f53686 Fixed misspelling in test comment. No functional change. 2023-05-07 07:39:51 -07:00
Eric Traut
50d967a17d Updated typeshed stubs to the latest version. 2023-05-06 11:06:13 -07:00
Eric Traut
f55ef6253f Simplified constructor validation logic through refactoring. 2023-05-06 10:56:21 -07:00
Eric Traut
5283c73690 Modified the logic (and associated behavior) for constructor validation in cases where a metaclass has a custom __call__ method. This is part of a larger effort to clean up constructor validation and make it more consistent with runtime behaviors. 2023-05-06 10:11:21 -07:00
Eric Traut
42a60aaf0e Changed behavior of logic that infers the type of the value and _value_ members of an enum instance. If the Enum class defines a __new__ method, these are evaluated as Any rather than a type based on their assigned value because the __new__ method can transform the value in ways that cannot be determined statically. 2023-05-06 10:08:05 -07:00
Eric Traut
2f5241e331 Changed overload behavior to evaluate an Any return type rather than Unknown if the presence of an Any argument results in an ambiguous overload selection and one or more of those overload signatures contains an explicit Any in its return type. This is a tweak to the solution introduced for https://github.com/microsoft/pyright/issues/5068. 2023-05-06 10:06:15 -07:00
Eric Traut
85a8b34aee Added instructions for adding a “pyright: checked” badge. 2023-05-06 08:26:44 -07:00
Eric Traut
a9a0a60a39 Moved badge to docs/img folder. 2023-05-06 08:25:03 -07:00
Eric Traut
f00d3e19cc Added static SVG badge for pyright. 2023-05-06 08:16:25 -07:00
Eric Traut
346efee56d Moved type evaluation logic for unary, binary and ternary operations out of the typeEvaluator module and into its own module. This is a refactoring with no functional change. 2023-05-06 00:22:06 -07:00
Eric Traut
49420be367 Moved constructor-related functionality out of typeEvaluator into its own dedicated module. This is a refactor with no functional changes. It's in preparation for some changes to the constructor validation logic. 2023-05-05 23:48:56 -07:00
Eric Traut
f20fe8221e Expanded special-case handling of .value and .name properties of Enum instance. It now handles non-literal cases by evaluating a union of all possible names or values defined in the enum. 2023-05-04 18:20:15 -07:00
Eric Traut
8d70000ad9 Added test case for PEP 712 converters that are constructors. 2023-05-04 11:23:56 -07:00
Eric Traut
be8f2c856d Added support for constructors to PEP 712 mechanism. This addresses https://github.com/microsoft/pyright/issues/5071. 2023-05-04 11:16:32 -07:00
Eric Traut
5894ce1ce9 Adjusted heuristic for dealing with ambiguous overloads due to unknown argument types. If one or both overloads include an Any in its return type, it now produces an Unknown result. This addresses https://github.com/microsoft/pyright/issues/5068. 2023-05-03 13:40:15 -07:00
Rich Chiodo
009aef317b
Push pylance changes to pyright (#5066) 2023-05-03 10:54:00 -07:00
Eric Traut
cdc8cfe143 Added support for type narrowing of TypedDicts with NotRequired entries with map patterns that use a literal str key pattern. This addresses https://github.com/microsoft/pyright/issues/5056. 2023-05-02 23:07:26 -07:00
Eric Traut
66b6672bef Published 1.1.306 2023-05-02 19:20:11 -07:00
Eric Traut
eba727a519 Eliminated the code that treats unions within value expressions as a UnionType object. This behavior caused various problems including a false positive in this case: https://github.com/microsoft/pyright/issues/5050. 2023-05-02 00:31:46 -07:00
Eric Traut
fae2e2f7ed Fixed typo in error message. 2023-05-01 22:58:56 -07:00
Erik De Bonte
6e95b76291
Fix broken link in mypy-comparison.md (#5046) 2023-05-01 14:42:54 -07:00
Erik De Bonte
d37f4c99ee
Add support for PEP 712 (#5034) 2023-05-01 14:27:12 -07:00
Rich Chiodo
1edb384271
Update dependabot problem (#5045) 2023-05-01 11:58:40 -07:00
Rich Chiodo
f460787a08
Idea for copy on write (#5031)
* Idea for copy on write

* Fix tests and hygiene

* Add a test for edit mode

* Handle opening of a new file in edit mode

* Refactor to use SourceFiles to track data instead.

* Use full edits instead

* Review feedback eliminate unused file too

* Move edits up one level
2023-05-01 11:20:21 -07:00
Eric Traut
f198a120d7 Added special-case handling for methods within generic classes parameterized by a ParamSpec when those methods use *args: P.args, **kwargs: P.kwargs in their signature and the callable signature captured by the ParamSpec is from a generic function. In this case, the TypeVar scope of the captured function is retained so its type variables can be solved when the method is solved. This is useful for generic callback protocol classes that implement a __call__ method. This addresses https://github.com/microsoft/pyright/issues/5033. 2023-04-30 18:38:57 -07:00
Eric Traut
b80f2b8f02 Improved type names in typeVarContext. No functional change. 2023-04-30 17:27:08 -07:00
Eric Traut
294a97de4f Implemented check for conditional statement operands. Such operands must support a __bool__ method that returns a bool return type. Any other type is treated as an error by the runtime. This addresses https://github.com/microsoft/pyright/issues/5039. 2023-04-30 17:25:58 -07:00
Eric Traut
704bd7022e Added support for a generic NamedTuple class — i.e. a class that uses NamedTuple as a base class along with type parameters defined in a Generic[...] base class and then uses these type parameters in type definitions for the NamedTuple entries. This addresses https://github.com/microsoft/pyright/issues/5036. 2023-04-29 11:07:18 -07:00
Eric Traut
8cbefe628b Fixed a bug in the --verifytypes command-line tool that affected the case where a submodule was specified (e.g. --verifytypes a.b.c) and the final nested module was a single file (e.g. c.py) rather than an __init__.py within a folder. This addresses https://github.com/microsoft/pyright/issues/4999. 2023-04-28 14:38:29 -07:00
Eric Traut
38e155fe8b Fixed a confusing and inappropriate diagnostic addendum when a function with positional-only parameters is assigned to another function with positional-only parameters but has a parameter count mismatch. The old logic output an inappropriate message about a keyword-only parameter. This addresses https://github.com/microsoft/pyright/issues/5032. 2023-04-28 13:54:52 -07:00
Heejae Chang
3be44c3242
Added a flag in resolve alias declaration so that we can skip early bail out (perf optimization) when needed. (#5028) 2023-04-28 00:21:18 -07:00
Eric Traut
88d0ed1170 Fixed bug that caused useLibraryCodeForTypes to default to false in the CLI if it was not overridden in the config file. Version 1.1.305 was intended to change the default to true, but it didn't. This addresses https://github.com/microsoft/pyright/issues/5029. 2023-04-27 22:15:46 -07:00
Eric Traut
332bfa8323 Fixed typo in comment. No functional change. 2023-04-27 20:24:17 -07:00
Eric Traut
2b74707fbf Changed the behavior of the reportIncompatibleMethodOverride check to exempt the case where the base class or override has a type that is defined by Callable[..., X]. The ... means that it's compatible with any signature. Also fixed a false negative in this check where the base method contains a **kwargs parameter but the override does not. This addresses https://github.com/microsoft/pyright/issues/1787. 2023-04-27 20:24:05 -07:00
Eric Traut
daba4a3eb9 Fixed inconsistent evaluation of a class type when calling a generic constructor that accepts a type[T] parameter and a union of classes is passed as an argument. This addresses https://github.com/microsoft/pyright/issues/5022. 2023-04-27 12:00:09 -07:00
Eric Traut
8b10b376d8 Fixed a bug that resulted in a false positive error when doing protocol matching when there are multiple levels of protocol inheritance and a method that uses Self in its signature. This addresses https://github.com/microsoft/pyright/issues/4966. 2023-04-27 09:53:58 -07:00
Eric Traut
06fc24c9a8 Added a map of open documents to the languageServerBase class. It is responsible for applying any delta changes and updating the contents for each of the workspaces associated with that file. This allows source code contents to be shared between workspaces, which reduces memory usage. It also eliminates a correctness issue that can occur if new workspaces are added after files are open. It addresses https://github.com/microsoft/pyright/issues/4994. 2023-04-27 09:53:13 -07:00
Eric Traut
924bf710b1 Fixed a bug that resulted in a false positive error when constructing a tuple of classes in the second argument of an isinstance or issubclass call. This addresses https://github.com/microsoft/pyright/issues/5018. 2023-04-26 19:38:43 -07:00
Eric Traut
2575969bf0 Fixed minor typo in comment. No functional change. 2023-04-26 19:21:22 -07:00
Eric Traut
5c4d9b6117 Fixed a bug in the isinstance and issubclass type narrowing when the types have no overlap and one or both is @final. In this case, the narrowing should result in a Never rather than an intersection type. This addresses https://github.com/microsoft/pyright/issues/5016. 2023-04-26 17:20:45 -07:00
Eric Traut
b231f03351 Fixed style issue. 2023-04-26 17:03:20 -07:00
Eric Traut
58b0a134ac Reduced the default output of the CLI. This addresses https://github.com/microsoft/pyright/issues/4594. 2023-04-26 16:51:21 -07:00