Commit Graph

5397 Commits

Author SHA1 Message Date
Eric Traut
12d5fe168f
Fixed a bug that results in an incorrect type evaluation of a higher-order function that is passed an overloaded function. This addresses #8898. (#8900) 2024-09-04 17:21:31 -07:00
Eric Traut
49235d38ba
Fixed a bug that causes incorrect type narrowing of expressions used within a tuple expression in the subject expression of a match statement. This addresses #8897. (#8899) 2024-09-04 16:46:25 -07:00
Eric Traut
9287bfa5f8
Fixed a bug that results in a false positive error during protocol matching because writable class variables defined in a named tuple or a frozen dataclass were considered read-only. This addresses #8829. (#8896) 2024-09-04 14:44:49 -07:00
Heejae Chang
2fecb178fd
removed duplicated code and use same method to create default workspace key (#8893) 2024-09-04 11:23:40 -07:00
Eric Traut
56183a3de4
Fixed recent regression that results in a false positive under certain specific circumstances involving higher-order functions that return generic callable types. This addresses #8852. (#8892) 2024-09-04 10:55:00 -07:00
Eric Traut
bf2c2bd7c5
Fixed a recent regression that results in a false positive type error when converting certain constructors (such as for the class defaultdict) to a callable type. This addresses #8840. (#8890) 2024-09-04 10:14:14 -07:00
Eric Traut
dda4b84b75
Fixed a recent regression that results in incorrect type evaluation when using a two-argument form of super() and the second argument is type[Self]. This addresses #8763. (#8889) 2024-09-04 08:13:39 -07:00
Eric Traut
8312965d54 Published 1.1.379 2024-09-03 16:40:12 -07:00
Eric Traut
7abaf1996a
Fixed a bug that results in confusing hover information for an attrs … (#8883)
* Fixed a bug that results in confusing hover information for an attrs field that uses a converter. This addresses #8881.

* Restored previous behavior for modules.
2024-09-03 13:49:03 -07:00
Eric Traut
c29f903809 Fixed bug that results in incorrect type evaluation when assigning a recursive type alias to a tuple or list. This addresses #8879. 2024-09-02 14:29:44 -07:00
Eric Traut
386b7fe0a5 Added check for concatenated bytes and str literals. This addresses #8871. 2024-09-01 17:45:21 -07:00
Eric Traut
689857dcf2
Added provisional support for draft PEP 747 and the TypeForm special form. (#8875) 2024-09-01 12:03:42 -07:00
Eric Traut
4773ded01f
Fixed a bug that can result in difficult-to-reproduce type evaluation errors when modifying code in your editor and using pyright as a language server. (#8873) 2024-09-01 08:14:44 -07:00
Eric Traut
e43b6af921
Incorporated a bunch of code cleanup and refactoring changes from a side branch in preparation for new functionality. (#8872) 2024-08-31 16:09:35 -07:00
Eric Traut
a1a83f114a Fixed bug that results in the incorrect type when the Callable special form is used in a value expression. 2024-08-30 14:51:31 -07:00
Eric Traut
c979baf30b Updated some diagnostic strings to refer to "type expression" rather than "type annotation" since they apply to some cases that don't involve annotations. 2024-08-30 14:51:09 -07:00
Erik De Bonte
ce64adc17b
Pull Pylance with Pyright 1.1.378 (#8851) 2024-08-28 16:05:36 -07:00
dependabot[bot]
2fa36386d0
Bump webpack from 5.90.1 to 5.94.0 in /packages/pyright (#8845)
Bumps [webpack](https://github.com/webpack/webpack) from 5.90.1 to 5.94.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.90.1...v5.94.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-27 20:55:52 -07:00
Eric Traut
9c003e9ff0 Published 1.1.378 2024-08-27 20:43:42 -07:00
Eric Traut
79a46a8dea
Fixed a bug that results in a false negative when overloads overlap due to default values. (#8844) 2024-08-27 14:26:36 -07:00
Eric Traut
2e11a3c6b9 Did a cleanup pass on overload tests, giving them better names. 2024-08-27 14:00:22 -07:00
Eric Traut
4dc82f79ff
Fixed bug that results in a reportIncompatibleMethodOverride diagnostic being reported in the wrong location in some cases involving decorators. This addresses #8842. (#8843) 2024-08-27 09:20:48 -07:00
Eric Traut
6c45f06e55
Fixed a bug that resulted in incorrect evaluation when converting a constructor to a callable and the constructed class has a metaclass with a __call__ method whose cls parameter is annotated with type[T]. This addresses https://github.com/microsoft/pylance-release/issues/6297. (#8837) 2024-08-26 14:04:12 -07:00
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
Eric Traut
3e448e7615
Fixed regression that resulted in a hang when determining whether an overload implementation with generics was compatible with its overloads. This addresses #8687. (#8706) 2024-08-08 17:29:08 -06:00
Kacie Kang
1f193580c8
Fix fileInfo null error (#8702)
* fix file info null reference

* check for binding

* removing fileinfo in if statement
2024-08-08 16:08:33 -07:00
Eric Traut
e8f0965e5b
Removed overly-complicated (and buggy) internal function setTypeArgsRecursive. (#8703) 2024-08-08 13:48:16 -06:00
Eric Traut
65ea3e95b4
Fixed bug that results in a false positive error when type argument for Literal doesn't follow type expression rules within a value expression context. This addresses 8696. (#8700) 2024-08-08 12:37:39 -06:00
Eric Traut
efda709120
Fixed a bug that results in a false positive reportInconsistentOverload error when the implementation of the overload includes a decorator that changes the type of the implementation to a non-function type. This addresses #8692. (#8699) 2024-08-08 12:26:27 -06:00
Eric Traut
2b603b9144
Modified OverloadedFunctionType interface in preparation for a follow-on change. Users of OverloadedFunctionType must now use the accessor functions to get the overloads and implementation. (#8695) 2024-08-08 09:32:21 -06:00
Eric Traut
8c628b0bc4 Fixed bug that results in a crash when an empty tuple is used to specialize a generic type alias parameterized by a ParamSpec. This addresses #8694. 2024-08-08 00:13:28 -06:00
Eric Traut
3d52679f59 Added optimization to shortcut overlapping overload checks if the diagnostic is suppressed. 2024-08-07 12:10:32 -06:00
Eric Traut
51c98aa945 Added small optimization that skips checks for overload consistency if these diagnostics are suppressed. 2024-08-07 12:06:15 -06:00
Eric Traut
f0c0dc8d4d Published 1.1.375 2024-08-06 20:32:59 -06:00
Eric Traut
e5889207ff Fixed bug that causes infinite recursion and memory exhaustion under certain circumstances involving recursive type aliases where the type alias is used as a type argument. This addresses #8670. 2024-08-06 16:39:26 -06:00
Eric Traut
1ab7801331
Fixed bug in type narrowing logic for value patterns, specifically when two enums with members of the same name are involved. This addresses #8674. (#8682) 2024-08-06 13:10:35 -06:00
Eric Traut
c285825dea
Allow Final and ClassVar to be combined in both directions within a dataclass. Previously, the Final qualifier needed to be the outermost. This addresses #8676. (#8678) 2024-08-06 11:44:51 -06:00
Eric Traut
08e02e450b
Added support for bool expansion to Literal[True] | Literal[False] during pattern matching when using value patterns. (#8677) 2024-08-06 11:11:47 -06:00
Eric Traut
c1df6595a1
Fixed a bug that results in incorrect type narrowing when using isinstance with an instance of a generic class as the first argument and a concrete subclass as the filter type. This addresses #8672. (#8675) 2024-08-06 10:30:12 -06:00
Eric Traut
35ab773671
Another round of simplification for TypeVar solving. Add support for recursive solutions (i.e. a TypeVar that has an upper or lower bound that depends on another TypeVar). (#8663) 2024-08-05 14:12:05 -06:00
Eric Traut
4d471f154f Updated typeshed stubs to the latest version. 2024-08-05 13:25:56 -06:00
Eric Traut
c10fa6d535
Fixed a bug that results in incorrect type narrowing for truthy/falsy type guards consisting of an Enum member when the enum class derives from ReprEnum. In this case, the "magic" of the enum implementation forwards the __bool__ call to the underlying value. This addresses #8658. (#8662) 2024-08-05 13:03:06 -06:00
Eric Traut
9a5643fc5f
Further simplified TypeVar constraint tracking and solving. Removed precomputed "lowerBoundNoLiterals" from tracker. (#8656) 2024-08-05 10:31:15 -06:00
Eric Traut
bf6eab2147
Fixed a bug that results in incorrect overload matching when one overload contains a zero-arity variant and another overload contains an *args (variadic) parameter. This addresses #8645. (#8654) 2024-08-05 01:34:02 -06:00
Eric Traut
4adf903331
Fixed bug that caused first argument of cast method on memoryview object to be treated as a type expression. Pyright was confusing this method with typing.cast. This addresses #8649. (#8651) 2024-08-04 14:49:43 -06:00
Eric Traut
fe0dc216f0
Fixed bug that results in a false positive error under certain circumstances when passing an overloaded function as an argument to a call. This addresses #8632. (#8644) 2024-08-03 01:12:51 -06:00
Eric Traut
ed65b44df3 Added subtyping support or IntEnum and StrEnum members. These literal values are subtypes of the corresponding literal int or str. This partly addresses #8641. 2024-08-02 23:01:20 -06:00
Eric Traut
24ed89d3ea Fixed bug in TypeVar auto-variance calculations for NamedTuples. Since NamedTuple variables are read-only, they should not cause a TypeVar to be invariant. 2024-08-02 18:46:35 -06:00
Eric Traut
d298d49981 Renamed constraint tracker method setConstraints to setBounds for clarity. 2024-08-02 14:36:19 -06:00
Eric Traut
c883ac067c Did a round of terminology cleanup for TypeVarTuples. No functional change. 2024-08-02 14:14:38 -06:00
Eric Traut
e22d2d2b1b
Did another round of simplification in the ParamSpec logic. (#8642) 2024-08-02 14:00:14 -06:00
Eric Traut
ce8c57f44d
Did a cleanup pass on the code that accesses the param types. Some code paths were not using the appropriate accessor functions, so they were ignoring specialized param types and using the unspecialized (declared) type instead. (#8640) 2024-08-02 12:55:33 -06:00
Eric Traut
5ad9f1fea1 Fixed bug that results in a false positive reportUnsupportedDunderAll warning when using the __all__.extend(x.__all__) form and the list of entries in x is empty. This addresses #8636. 2024-08-02 08:10:19 -06:00
Eric Traut
7802376828 Changed disableLanguageServices feature to apply to hover text as well as other language services. Previously, hover text was excluded. This addresses #8639. 2024-08-02 07:59:47 -06:00
Eric Traut
842ab02c34
Fixed bug in the functools.partial logic that results in incorrect handling of an unpacked TypedDict when used with a **kwargs parameter. This addresses #8617. (#8630) 2024-07-31 23:12:50 -07:00
Eric Traut
33d2937b8c
Removed constraint solving logic from constraint tracker. All such logic should be contained within the constraint solver. (#8629) 2024-07-31 18:40:15 -07:00
Eric Traut
327dcfc42a
Removed a bunch of redundant and special-case handling of param specs that's no longer needed. (#8627) 2024-07-31 16:29:23 -07:00
Eric Traut
2eb14cba65
Separated constraint solving from the application of the solved type variables. (#8624) 2024-07-31 12:37:50 -07:00
Eric Traut
d300291291
Fixed bug that leads to internal data structure corruption and subsequent false positive errors in certain cases involving unions of Unknown types that include type aliases. This addresses #8608. (#8621) 2024-07-31 09:35:50 -07:00
Eric Traut
7ba1c62bdc
Fixed bug that results in a false positive error when a covariant type variable that is scoped to a method is used in a parameter annotation. This addresses #8614. (#8615) 2024-07-30 22:24:27 -07:00
Eric Traut
5992d8aae2 Published 1.1.374 2024-07-30 21:12:50 -07:00
Eric Traut
7532c0f5ca
Type var cleanup10 (#8613)
* Renamed TypeVarContext to ConstraintTracker in preparation for further refactoring. No functional change.

* Did some code cleanup in the constraint solver module.
2024-07-30 21:10:56 -07:00
Eric Traut
0b7d2ca240 Fixed regression that results in a false negative when an illegal type expression form is used within a PEP 695 constrained TypeVar definition. 2024-07-30 16:14:45 -07:00
Eric Traut
45161ef964
Fixed bug that results in a false positive when using a two-argument form of super() outside of a class. This addresses #8604. (#8611) 2024-07-30 15:59:57 -07:00
Eric Traut
28600608a6
Next round of simplification. Removed higherOrderTypeVarScopeIds. (#8610) 2024-07-30 15:10:45 -07:00
Eric Traut
e1d377efcd
Another round of cleanup and simplification. (#8609) 2024-07-30 14:36:51 -07:00
Eric Traut
3e936c7720
Further simplified code for tracking type vars. (#8606) 2024-07-30 12:44:20 -07:00
Eric Traut
8b5c1da2b5
Further simplified and cleaned up type var application code. (#8605) 2024-07-30 11:39:31 -07:00
Eric Traut
6913347aa8
Fixed bug that results in false positive error under certain circumstances when solving type variables that involve literal values. This addresses #8133 and #8048. (#8603) 2024-07-30 10:48:06 -07:00
Eric Traut
74345cc15f
Further simplified code in type var application code. (#8601) 2024-07-30 10:13:22 -07:00
Eric Traut
c9543bc987
Further simplification of the logic involved in type var solving. (#8600)
This addresses #8301 and #5855.
2024-07-30 10:00:00 -07:00
Eric Traut
b629011afc Added small optimization for argument type checking that saves some memory and time. 2024-07-30 00:48:40 -07:00
Eric Traut
a82a7b972c
Did more cleanup of the "apply solved type var" code path. (#8598) 2024-07-29 22:50:49 -07:00
Eric Traut
c82019fec5
Renamed "external" and "internal" type vars to "free" and "bound" respectively. This terminology is more reflective of their true meaning. No functional change. (#8595) 2024-07-29 21:33:50 -07:00
Eric Traut
85651bd849 Renamed "in-scope placeholder type variables" to "unification variables". No functional change. 2024-07-29 20:59:05 -07:00
Eric Traut
67f0b8d173
Simplified some of the logic involved in type var constraint solving. (#8594) 2024-07-29 20:50:55 -07:00
Eric Traut
4d2d197bff
Started to simplify some of the code involved in type var solving. (#8590)
Improved handling of type variable matching when a callee's parameter is a union of two or more "naked" type variables (like `S | T`).
2024-07-29 17:30:33 -07:00
Eric Traut
173ced142d
Fixed bug that can result in a false positive when calling the constructor within a class that has unannotated __init__ or __new__ method parameters. (#8582) 2024-07-29 11:03:28 -07:00
Eric Traut
e99b7726c8
Fixed bug that can result in a false negative when a function return type is a TypeVar and the function falls through and implicitly returns a None. (#8581) 2024-07-29 10:46:58 -07:00
Eric Traut
c2f5d26f03
Adjusted the heuristics for constraint solving to favor solutions of type T over type[T]` when both are valid. (#8579) 2024-07-28 22:26:34 -07:00
Eric Traut
cfd1a3710a Fixed bugs in a few test cases. 2024-07-28 13:19:58 -07:00
Eric Traut
f306d366dd
Modified heuristics in T is None type narrowing logic to handle TypeVars with no bounds better. The previous logic was arguably correct, but it produced results that were unexpected by some users. This addresses #8575. (#8578) 2024-07-28 10:36:47 -07:00
Eric Traut
d3d24d35bd
Added convenience accessor functions for TypeVars to test for constra… (#8576)
* Added convenience accessor functions for TypeVars to test for constraints, bounds, and Self. No functional change.

* Fixed style issue
2024-07-28 09:01:30 -07:00
Eric Traut
7e8dfb76ad Added support for @deprecated on __new__ methods used implicitly during a class constructor call. This addresses #8574. 2024-07-28 08:11:38 -07:00
Eric Traut
513d2ea697
Added support for @deprecated on __bool__ magic method used by not operator. (#8573) 2024-07-27 23:17:23 -07:00
Eric Traut
ed679c69d3
Added support for @deprecated decorator on magic methods for unary and binary operations. (#8572) 2024-07-27 22:42:20 -07:00
Eric Traut
5d68698462
Fixed bug that results in a false negative if a __set__ descriptor method is marked deprecated and is implicitly accessed using an augmented assignment operator, as in a.x += 1. (#8571) 2024-07-27 21:57:49 -07:00
Eric Traut
3931155adb
Fixed recent regression that can lead to a crash. (#8570) 2024-07-27 21:49:13 -07:00
Eric Traut
28b5427d55 Renamed some concepts in the typeVarContext and constraintSolver modules in preparation for a larger change. 2024-07-27 15:44:03 -07:00
Eric Traut
5397ee3470 Removed import cycle in typeVarContext module. 2024-07-27 14:58:53 -07:00
Eric Traut
bffbc33b69 Cleaned up data structures for TypeVarType to provide better type protection for ParamSpec and TypeVarTuple fields. Renamed TypeVarTuple test cases to conform better to internal terminology.
(cherry picked from commit 0a15f335ec5bba5f1b0997ffec4c622dad74bf13)
2024-07-27 14:52:58 -07:00
Eric Traut
01a82e2023 Renamed some internal symbol names for brevity (parameter => param). No functional change. 2024-07-27 12:03:36 -07:00
Eric Traut
a74871d46f Simplified cloneForSpecialization call to improve brevity and readability. 2024-07-27 11:21:49 -07:00
Eric Traut
8cab57e657 Renamed some internal symbol names for brevity (argument => arg). No functional change. 2024-07-27 11:02:57 -07:00
Eric Traut
31df557056 Removed some unused functionality from the TypeVarContext. 2024-07-27 10:39:52 -07:00
Eric Traut
4b91a0b222 Moved type complexity calculation into its own module. 2024-07-27 10:31:13 -07:00
Eric Traut
2c4032a920 Simplified TypeVarContext by removing some of the special-case handling for tupleTypeArgs. 2024-07-27 10:20:33 -07:00
Eric Traut
2bbd1bf288
Fixed a bug that can result in incorrect type evaluation when an isinstance type narrowing results in an intersection type. (#8564) 2024-07-27 10:17:05 -07:00
Eric Traut
7e7ad07453
Removed special-casing for None that is no longer needed. (#8562) 2024-07-26 21:04:49 -07:00
Eric Traut
c385edf274
Added missing check for Final variable assigned in a loop. (#8561) 2024-07-26 17:08:24 -07:00
Eric Traut
5f145eb010
Fixed a bug that results in incorrect type narrowing when tuples are used in conjunction with TypeIs. This addresses #8554. (#8559) 2024-07-26 16:14:37 -07:00