[ty] Improve diagnostics for unsupported comparison operations#21737
Merged
AlexWaygood merged 3 commits intomainfrom Dec 2, 2025
Merged
[ty] Improve diagnostics for unsupported comparison operations#21737AlexWaygood merged 3 commits intomainfrom
AlexWaygood merged 3 commits intomainfrom
Conversation
9f27eae to
577f7b9
Compare
Diagnostic diff on typing conformance testsChanges were detected when running ty on typing conformance tests--- old-output.txt 2025-12-02 19:54:53.533433718 +0000
+++ new-output.txt 2025-12-02 19:54:57.115460740 +0000
@@ -293,7 +293,7 @@
dataclasses_kwonly.py:61:14: error[parameter-already-assigned] Multiple values provided for parameter `b`
dataclasses_match_args.py:42:1: error[unresolved-attribute] Class `DC4` has no attribute `__match_args__`
dataclasses_match_args.py:49:1: error[type-assertion-failure] Type `tuple[()]` does not match asserted type `Unknown | tuple[()]`
-dataclasses_order.py:50:4: error[unsupported-operator] Operator `<` is not supported for types `DC1` and `DC2`
+dataclasses_order.py:50:4: error[unsupported-operator] Operator `<` is not supported between objects of type `DC1` and `DC2`
dataclasses_postinit.py:28:7: error[unresolved-attribute] Object of type `DC1` has no attribute `x`
dataclasses_postinit.py:29:7: error[unresolved-attribute] Object of type `DC1` has no attribute `y`
dataclasses_slots.py:66:1: error[unresolved-attribute] Class `DC6` has no attribute `__slots__`
@@ -301,7 +301,7 @@
dataclasses_transform_class.py:63:1: error[invalid-assignment] Property `id` defined in `Customer1` is read-only
dataclasses_transform_class.py:66:8: error[missing-argument] No arguments provided for required parameters `id`, `name`
dataclasses_transform_class.py:66:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2
-dataclasses_transform_class.py:72:6: error[unsupported-operator] Operator `<` is not supported for types `Customer1` and `Customer1`
+dataclasses_transform_class.py:72:6: error[unsupported-operator] Operator `<` is not supported between two objects of type `Customer1`
dataclasses_transform_class.py:82:8: error[missing-argument] No argument provided for required parameter `id`
dataclasses_transform_class.py:82:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2
dataclasses_transform_class.py:122:1: error[invalid-assignment] Property `id` defined in `Customer3` is read-only
@@ -343,7 +343,7 @@
dataclasses_transform_field.py:75:1: error[missing-argument] No argument provided for required parameter `name`
dataclasses_transform_field.py:75:16: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1
dataclasses_transform_func.py:56:1: error[invalid-assignment] Object of type `Literal[3]` is not assignable to attribute `name` of type `str`
-dataclasses_transform_func.py:60:6: error[unsupported-operator] Operator `<` is not supported for types `Customer1` and `Customer1`
+dataclasses_transform_func.py:60:6: error[unsupported-operator] Operator `<` is not supported between two objects of type `Customer1`
dataclasses_transform_func.py:64:36: error[unknown-argument] Argument `salary` does not match any known parameter
dataclasses_transform_func.py:70:8: error[missing-argument] No arguments provided for required parameters `id`, `name`
dataclasses_transform_func.py:70:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2
@@ -352,7 +352,7 @@
dataclasses_transform_meta.py:63:1: error[invalid-assignment] Property `id` defined in `Customer1` is read-only
dataclasses_transform_meta.py:66:8: error[missing-argument] No arguments provided for required parameters `id`, `name`
dataclasses_transform_meta.py:66:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2
-dataclasses_transform_meta.py:73:6: error[unsupported-operator] Operator `<` is not supported for types `Customer1` and `Customer1`
+dataclasses_transform_meta.py:73:6: error[unsupported-operator] Operator `<` is not supported between two objects of type `Customer1`
dataclasses_transform_meta.py:83:8: error[missing-argument] No argument provided for required parameter `id`
dataclasses_transform_meta.py:83:18: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 2
dataclasses_transform_meta.py:103:1: error[invalid-assignment] Property `id` defined in `Customer3` is read-only
|
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
unsupported-operator |
0 | 0 | 814 |
unsupported-base |
0 | 1 | 0 |
| Total | 0 | 1 | 814 |
MichaReiser
reviewed
Dec 2, 2025
Member
MichaReiser
left a comment
There was a problem hiding this comment.
Nice, I mainly reviewed the diagnostics and I think we should make them more concise
...ns.md_-_Comparison___Intersec…_-_Diagnostics_-_Unsupported_operator…_(27f95f68d1c826ec).snap
Outdated
Show resolved
Hide resolved
...ns.md_-_Comparison___Intersec…_-_Diagnostics_-_Unsupported_operator…_(27f95f68d1c826ec).snap
Outdated
Show resolved
Hide resolved
...ns.md_-_Comparison___Intersec…_-_Diagnostics_-_Unsupported_operator…_(27f95f68d1c826ec).snap
Outdated
Show resolved
Hide resolved
577f7b9 to
32f053c
Compare
CodSpeed Performance ReportMerging #21737 will not alter performanceComparing Summary
Footnotes
|
MichaReiser
approved these changes
Dec 2, 2025
460168e to
bcf5c78
Compare
Member
Author
…er subdiagnostics for tuples
bcf5c78 to
a68fafc
Compare
AlexWaygood
added a commit
that referenced
this pull request
Dec 2, 2025
dcreager
added a commit
that referenced
this pull request
Dec 3, 2025
* origin/main: [ty] Improve `@override`, `@final` and Liskov checks in cases where there are multiple reachable definitions (#21767) [ty] Extend `invalid-explicit-override` to also cover properties decorated with `@override` that do not override anything (#21756) [ty] Enable LRU collection for parsed module (#21749) [ty] Support typevar-specialized dynamic types in generic type aliases (#21730) Add token based `parenthesized_ranges` implementation (#21738) [ty] Default-specialization of generic type aliases (#21765) [ty] Suppress false positives when `dataclasses.dataclass(...)(cls)` is called imperatively (#21729) [syntax-error] Default type parameter followed by non-default type parameter (#21657) new module for parsing ranged suppressions (#21441) [ty] `type[T]` is assignable to an inferable typevar (#21766) Fix syntax error false positives for `await` outside functions (#21763) [ty] Improve diagnostics for unsupported comparison operations (#21737) Move `Token`, `TokenKind` and `Tokens` to `ruff-python-ast` (#21760) [ty] Don't confuse multiple occurrences of `typing.Self` when binding bound methods (#21754) Use our org-wide Renovate preset (#21759) Delete `my-script.py` (#21751) [ty] Move `all_members`, and related types/routines, out of `ide_support.rs` (#21695)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
On
main:Concise diagnostics on
main:With PR:
Concise diagnostics with PR:
Test Plan
Mdtests and snapshots