Commit Graph

5274 Commits

Author SHA1 Message Date
Eric Traut
e87bda9f02
Changed the default value of the disableBytesTypePromotions setting from false to true. It has been over two years since PEP 688 was accepted, so it's time for us to stop treating bytes as an alias for bytes | bytearray | memoryview. This is a breaking change and may require an update to the pyright configuration for some code bases. This addresses #8834. (#8835) 2024-08-26 11:40:16 -07:00
Eric Traut
bdea6d0064
Added new type utils function isLiteralLikeType and fixed a few literal-related bugs that were masked by other logic. (#8828) 2024-08-25 09:43:28 -07:00
Eric Traut
ecef512ade Improved consistency of error messages that involve type mismatches. Switched to the (now standardized) term "assignable". 2024-08-25 09:33:05 -07:00
Eric Traut
9e21b36ddc Minor code clean-ups from working branch. No functional change. 2024-08-25 09:30:31 -07:00
Eric Traut
acc52c7420
Fixed bug that results in a crash in very specific circumstances that involve binding a method parameterized by a function-scoped ParamSpec. This addresses #8823. (#8824) 2024-08-23 19:31:04 -07:00
Eric Traut
020dea1381
Added some code improvements from a working branch: (#8822)
* Added some code improvements from a working branch:
* Created a shortened "fileId" for each source file. This reduces memory used for tracking symbols and TypeVars that are scoped to files.
* Removed some unused or redundant code.
* Added assertNever calls to catch potential bugs.
* Renamed a few symbols for consistency and readability.
* Improved handling of literal type expressions that are lazily parsed.
* Refactored literal type printing into a utility module.

* Fixed style issue.
2024-08-23 18:13:12 -07:00
PylanceBot
ce3d4c1fb7
[PylanceBot] Pull Pylance with Pyright 1.1.377 (#8811)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-08-22 15:04:13 -07:00
PylanceBot
ede08a0211
[PylanceBot] Pull Pylance with Pyright 1.1.377 (#8808)
* pull-pylance-with-pyright-1.1.377-10512633325

* remove duplicate line

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bill Schnurr <bschnurr@microsoft.com>
2024-08-22 12:26:42 -07:00
Eric Traut
16879a1839
Fixed a bug that results in false negatives for errors in argument expressions used in a call to functools.partial in some cases. This same issue also causes symbols accessed in these arg expressions to not be marked as referenced. This addresses #8807. (#8809) 2024-08-22 10:48:21 -07:00
Rich Chiodo
38b1bd29c6
Ensure default version and platform only once (#8802)
* Ensure default version and platform only once

* Refactor execEnv creation to after everything else

* Fix tests to do the same thing as service

* Comment missing .

* Default python version to behave as it did before
2024-08-21 16:12:36 -07:00
Eric Traut
a9bd905060 Fixed bug that results in incorrect logging of the pythonVersion string. This addresses #8798. 2024-08-21 08:47:48 -07:00
Eric Traut
2876baefd8 Published 1.1.377 2024-08-20 18:40:51 -07:00
Eric Traut
89193935f1
Added unreachable code reporting for case statements that are never matched based on type analysis. (#8788) 2024-08-20 08:04:53 -07:00
Eric Traut
c8be6d8ab6 Updated typeshed stubs to the latest version. 2024-08-19 20:59:46 -07:00
Eric Traut
1a7ad15591 Integrating some code cleanups done on a working branch. 2024-08-19 20:53:11 -07:00
Eric Traut
a93b66f06a
Fixed bug that results in a false positive error under very specific conditions involving a recursive type alias that is defined in terms of another type alias. This addresses #8784. (#8785) 2024-08-19 11:26:53 -07:00
Eric Traut
0b2dc24b79
Changed type checking logic to retain a reference to default expressions in function signatures, including synthesized signatures (such as __init__ methods in dataclasses). This allows the original default value expression to be printed in error messages and language server strings. This addresses #8781. (#8783) 2024-08-19 10:04:17 -07:00
Eric Traut
48bb33b46b
Fixed a bug that leads to incorrect type evaluation in certain specific conditions involving a function decorator with an return type inferred from an inner function parameterized by a ParamSpec. This addresses #8779. (#8780) 2024-08-17 09:00:40 -07:00
Eric Traut
bea4dc91b5
Fixed a bug that leads to a crash when --pythonversion and --threads CLI options are used together. This addresses #8775. (#8776) 2024-08-16 21:42:03 -07:00
Eric Traut
c42a1587b4
Fixed a bug that results in a false positive error when assigning a TypeGuard[T] or TypeIs[T] to a supertype of bool (like int). This addresses #8769. (#8771) 2024-08-16 00:06:36 -07:00
Eric Traut
ea55470da5
Fixed bug that results in a crash under certain circumstances when a ParamSpec without a scope is used illegally to specialize a class. This addresses #8757. (#8768) 2024-08-15 19:07:42 -07:00
Eric Traut
deaf2641cf Refactored binary operator code for readability. No functional change. 2024-08-13 22:46:55 -06:00
Eric Traut
7fd5ed20be Published 1.1.376 2024-08-13 17:56:41 -06:00
Eric Traut
796a483119
Fixed bug that leads to a hang under certain circumstances involving deeply-nested higher-order functions. This addresses #8723. (#8752) 2024-08-13 09:21:14 -06:00
Eric Traut
c9a4eb2252
Changed behavior for protocols that have methods with method-scoped type variables. These are no longer treated as free type variables during protocol matching, so they can be used to support rank-2 polymorphism. This behavior is not currently dictated by the typing spec, but it is more consistent with mypy. This addresses #8685. (#8751) 2024-08-12 23:55:05 -06:00
Eric Traut
cef8bbb903
Fixed bug that leads to false positive error when a protocol has a read-only property a class has a Final variable. This addresses #8744. (#8747) 2024-08-11 19:50:02 -06:00
Eric Traut
aff4bfbfa3 Did some code cleanup with unpacked tuples and TypeVarTuples. 2024-08-11 00:38:15 -06:00
Eric Traut
2c9c42481f Removed vestigial code in Union type arg logic. 2024-08-10 23:05:27 -06:00
Eric Traut
fe3eca368a
Fixed bug that results in a confusing type in an error message when isinstance type narrowing between a type and another type creates a subclass. (#8741) 2024-08-10 18:32:46 -06:00
Eric Traut
142daa0a07
Removed some unnecessary special casing of None in type guard logic. (#8740) 2024-08-10 18:23:59 -06:00
Eric Traut
3905cfb852
Another round of simplification for callable return types. (#8737) 2024-08-10 13:26:07 -06:00
Eric Traut
2b82d07f69 Added small performance optimization in checker to avoid generating a diagnostic message in cases where it won't be used. 2024-08-10 12:42:17 -06:00
Eric Traut
913d18d960
Renamed some internal functions for readability and added options parameter to getEffectiveReturnType function. This is in preparation for a more involved change to fix #8723. (#8736) 2024-08-10 12:40:29 -06:00
Eric Traut
07ca233ba7 Updated typescript compiler version from 5.2 to 5.5.4 to avoid a bug I was hitting. 2024-08-10 10:58:10 -06:00
Eric Traut
1a17c0aa6b
Changed synthesized comparison methods (__lt__, etc.) for dataclasses when order=True to use Self rather than an instance of the class. This is not only more consistent with other synthesized methods, but it also preserves covariance of type variables if the dataclass is frozen. (#8734) 2024-08-10 10:27:32 -06:00
Eric Traut
465b04c80b Fixed a bug in the code that detects attribute docstrings to prevent it from walking all the way to the top of the parse tree. 2024-08-10 09:52:18 -06:00
Eric Traut
4fc5de5c1e
Fixed a false positive error when solving type variables in a call that involves a lambda. This addresses #8714. (#8730) 2024-08-10 00:47:49 -06:00
Rich Chiodo
f85e257026
Special case pythonPath to also come from the languageServer (#8728)
* Special case pythonPath to also come from the languageServer

* Compare URI correctly
2024-08-09 18:49:18 -06:00
Rich Chiodo
2aa9bf4c20
Reapply the compiler flags change but separate out the 'language server' specific settings (#8726)
* Document different types of 'compiler' flags and ensure merging of flags is consistent (#8704)

* Make sure config options cannot be overridden by settings.json

* Make sure extraPaths and python env information is updated from the command line

* Change fromVsCodeExtension to fromLanguageServer

* Separate command line options into json ones and language server ones

* Fix build error
2024-08-09 16:15:38 -07:00
Eric Traut
152350997d
Enhanced argument-to-parameter matching logic to support dictionary unpacking where the dict key type is a union of literals. This addresses #8671. (#8724) 2024-08-09 15:30:43 -06:00
Eric Traut
de0386d690 Revert "Document different types of 'compiler' flags and ensure merging of flags is consistent (#8704)"
This reverts commit a86210ccb7.
2024-08-09 13:20:55 -06:00
Eric Traut
421a87fd8a
Improved consistency of parameter name restrictions for the reportSelfClsParameterName check. Previously, different rules were applied to __new__ and class methods within metaclasses. This addresses #8717. (#8720) 2024-08-09 13:11:34 -06:00
Rich Chiodo
a86210ccb7
Document different types of 'compiler' flags and ensure merging of flags is consistent (#8704)
* Make sure config options cannot be overridden by settings.json

* Make sure extraPaths and python env information is updated from the command line

* Change fromVsCodeExtension to fromLanguageServer
2024-08-09 10:38:33 -07:00
Eric Traut
f68a616eb2 Fixed bug that produces signatures with extra (unnecessary) positional-only and keyword-only separators when using a TypedDict with zero fields. This addresses #8712. 2024-08-09 08:39:51 -06:00
Eric Traut
778509b20d Cleaned up some out-of-date comments and removed a circular import. 2024-08-09 00:24:02 -06:00
Eric Traut
55e1681568
Fixed bug that results in a false negative reportIncompatibleMethodOverride when the child class method uses a type parameter that is scoped to the child class. This addresses #8622. (#8711) 2024-08-09 00:04:00 -06:00
Eric Traut
fd68169161 Renamed PopulateExpectedType flag and clarified its purpose. 2024-08-08 19:32:59 -06:00
Eric Traut
77dc8848c5 Simplified internal validateArgTypes function. 2024-08-08 19:26:16 -06:00
Eric Traut
93115f9232
Renamed OverloadedFunctionType to OverloadedType for brevity and to reflect the fact that non-function types are now supported for overloads. No functional change, just a rename. (#8708) 2024-08-08 18:16:30 -06:00
Eric Traut
1d5420cb75
Further simplified TypeVar constraint tracking and solving. Removed the need to track separate constraints for dest and src. (#8707) 2024-08-08 17:58:48 -06:00