[ty] Enable unused-ignore-comment by default#22474
Conversation
Diagnostic diff on typing conformance testsChanges were detected when running ty on typing conformance tests--- old-output.txt 2026-01-09 10:56:08.437298717 +0000
+++ new-output.txt 2026-01-09 10:56:08.736299323 +0000
@@ -228,6 +228,7 @@
constructors_call_new.py:125:42: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Self@__new__`
constructors_call_new.py:140:47: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Class11[int]`
constructors_call_new.py:145:1: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `type[Class11[int]]`, found `<class 'Class11[str]'>`
+constructors_call_type.py:19:55: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
constructors_call_type.py:40:5: error[missing-argument] No arguments provided for required parameters `x`, `y` of function `__new__`
constructors_call_type.py:50:5: error[missing-argument] No arguments provided for required parameters `x`, `y` of bound method `__init__`
constructors_call_type.py:59:9: error[too-many-positional-arguments] Too many positional arguments to bound method `__init__`: expected 1, got 2
@@ -391,6 +392,11 @@
directives_reveal_type.py:19:5: error[missing-argument] No argument provided for required parameter `obj` of function `reveal_type`
directives_reveal_type.py:20:20: error[too-many-positional-arguments] Too many positional arguments to function `reveal_type`: expected 1, got 2
directives_type_checking.py:11:14: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
+directives_type_ignore_file1.py:11:7: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
+directives_type_ignore_file1.py:14:17: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
+directives_type_ignore_file2.py:7:1: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
+directives_type_ignore_file2.py:9:7: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
+directives_type_ignore_file2.py:12:17: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
directives_type_ignore_file2.py:14:10: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
directives_version_platform.py:14:17: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
directives_version_platform.py:19:17: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
@@ -1023,4 +1029,4 @@
typeddicts_usage.py:28:17: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
typeddicts_usage.py:28:18: error[invalid-key] Unknown key "title" for TypedDict `Movie`: Unknown key "title"
typeddicts_usage.py:40:24: error[invalid-type-form] The special form `typing.TypedDict` is not allowed in type expressions
-Found 1025 diagnostics
+Found 1031 diagnostics
|
|
|
The typing conformance results are a bit funny. ty picks up the nested # > A # type: ignore comment on a line by itself at the top of a file, before any
# > docstrings, imports, or other executable code, silences all errors in the file.
# > Blank lines and other comments, such as shebang lines and coding cookies, may
# > precede the # type: ignore comment.I think that's fine |
|
Hmm, why do we see changes on mypy primer. Does our mypy primer override no longer work? |
AlexWaygood
left a comment
There was a problem hiding this comment.
Nice. I still think a subdiagnostic that mentions the config option would be good, if we're emitting the diagnostic on a type: ignore comment rather than a ty: ignore comment. And I think we should definitely mention the config option in the docs for the rule.
| @@ -24,10 +24,10 @@ use crate::{Db, declare_lint, lint::LintId}; | |||
|
|
|||
| declare_lint! { | |||
There was a problem hiding this comment.
We should mention and link to the configuration option in the docs here, in case users get confused about ty complaining about ignore comments they have in place for other type checkers
This seems noisy to me. It's an extra line that you always see. |
|
We can consider it separately, it doesn't need to block this |
|
Ahh no. The reason we see the mypy primer changes is because we use the same (the new) configuration for both the baseline and the new ty binary but the old ty binary required explicilty enabling the rule |
They enabled unused-type-ignore-comment as per astral-sh/ruff#22474 which required a few code changes: - cloud_connector - simplify and prefer match over mutliple if tests anyway for an enum - remove several ignores which were simply not needed any more (ty correctly doing its job!) - dp_node - correctly set a type to include None - edge_orchestrator remove unused __new__ - the same function (which IS used) is in get_instance() - add some types where missing
|
Isn't the rule |
unused-type-ignore-comment by defaultunused-ignore-comment by default
|
It's also |
|
Thanks, this is fixed in https://github.com/astral-sh/ty/releases/tag/0.0.11 and I've put up a PR for the changelog: astral-sh/ty#2461 |
Summary
Closes astral-sh/ty#278