Callables whose return value is ignored
def foo(callback):
callback()
There's a few ways to type this function:
def foo(callback: Callable[[], None]) -> None: ...
def foo(callback: Callable[[], Any]) -> None: ...
def foo(callback: Callable[[], object]) -> None: ...
Callable[[], None] is not great, because it doesn't allow you to pass a callback that does return something; that will also work at runtime, and the return value is ignored. When I learned about this, I changed my callbacks to use Callable[[], Any] instead. But Callable[[], object] would be even better.
We could check for this, but does it belong to this tool? This lint isn't really stub-specific.
We could check for this, but does it belong to this tool? This lint isn't really stub-specific.
I'm starting to wonder if we should split the tool in two: one flake8 plugin for checks which only apply for stubs, another which has typing-related checks for .pyi files and .py files alike.
Or maybe we should just bite the bullet and add the necessary complexity to make the plugin .py-compatible as well, since an increasing number of our checks apply to both file types.
We could also try to get some of the non-pyi-specific checks accepted into flake8/pyflakes(?).
We could also try to get some of the non-pyi-specific checks accepted into flake8/pyflakes(?).
We could try, but I think they would probably be rejected. I think the checks we have here are probably too typing-specific.
There are other plugins that specialise in providing checks for annotations, e.g. https://github.com/sco1/flake8-annotations. The checks https://github.com/sco1/flake8-annotations currently does are pretty basic, though, imo.