[ty] Improve diagnostic when callable is used in a type expression instead of collections.abc.Callable or typing.Callable#22180
Merged
AlexWaygood merged 1 commit intomainfrom Dec 24, 2025
Conversation
…instead of `collections.abc.Callable` or `typing.Callable`
Diagnostic diff on typing conformance testsChanges were detected when running ty on typing conformance tests--- old-output.txt 2025-12-24 18:34:45.142051595 +0000
+++ new-output.txt 2025-12-24 18:34:47.321063280 +0000
@@ -91,8 +91,8 @@
annotations_forward_refs.py:55:11: error[invalid-type-form] Module `types` is not valid in a type expression
annotations_forward_refs.py:80:14: error[unresolved-reference] Name `ClassF` used when not defined
annotations_forward_refs.py:82:11: error[invalid-type-form] Variable of type `Literal[""]` is not allowed in a type expression
-annotations_forward_refs.py:87:9: error[invalid-type-form] Variable of type `def int(self) -> None` is not allowed in a type expression
-annotations_forward_refs.py:89:8: error[invalid-type-form] Variable of type `def int(self) -> None` is not allowed in a type expression
+annotations_forward_refs.py:87:9: error[invalid-type-form] Function `int` is not valid in a type expression
+annotations_forward_refs.py:89:8: error[invalid-type-form] Function `int` is not valid in a type expression
annotations_forward_refs.py:95:1: error[type-assertion-failure] Type `str` does not match asserted type `Unknown`
annotations_forward_refs.py:96:1: error[type-assertion-failure] Type `int` does not match asserted type `Unknown`
annotations_generators.py:86:21: error[invalid-return-type] Return type does not match returned value: expected `int`, found `types.GeneratorType`
|
|
Member
Author
Cool that even with the new "Did you mean...?" suggestion, the diagnostic is still more concise than it was previously 😄 |
charliermarsh
approved these changes
Dec 24, 2025
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
I noticed when reviewing the ecosystem report for #22145 that ibis makes this mistake. Mypy has a special-cased diagnostic for this, and there's no reason we can't too.
Test Plan
snapshot added