PLR1711, RET501 should exempt annotated function where return type isn’t -> None
#3704
Labels
bug
Something isn't working
-> None
#3704
Ruff flags PLR1711 useless-return and RET501 unnecessary-return-none in this code:
But mypy complains if
return None
is removed:or if
return None
is changed toreturn
:mypy can be appeased by changing the return type annotation to
-> None
, and that’s okay in many cases (e.g.Callable[..., None]
covariantly coerces toCallable[..., str | None
), but it’s not without problems—for example, it prevents a derived class from overriding the method to return astr
.So I think RET501 and PLR1711 should exempt annotated functions with a return type other than
-> None
.The text was updated successfully, but these errors were encountered: