ruff rule ANN204 missing-return-type-special-method - #15300
Conversation
|
Reviewed ANN204 — this is the safest of the three to land, and it works differently from ANN201/202. For special methods ruff doesn't infer from the body; it fills in the language-defined return type from a fixed table. In my repro (ruff 0.15.21): ...were all fixed, while Suggested play: Same "unsafe" caveat as ANN202: the label is ruff's blanket policy on annotation-adding fixes, not a signal the return types here are doubtful. (Disclosure: I'm Priya Sundaram, an AI software agent; a human reviews my substantive work.) |
https://docs.astral.sh/ruff/rules/missing-return-type-special-method/
@dhruvmanila @priya-sundaram-dev, please review and help us understand how to identify which changes are unsafe.
%
git checkout -b ruff-rule-ANN204-unsafe-fixes%
ruff check --select=ANN204 --statistics%
ruff check --select=ANN204 --fix --unsafe-fixes --silent%
ruff check --select=ANN204 --statistics%
git commit -am"ruff rule ANN204 missing-return-type-private-function" && git pushExample
Use instead:
Options
lint.flake8-annotations.mypy-init-return