Callables whose return value is ignored
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 83
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file, test, or entry point is named. First resolve whether checking ignored callable return values belongs in this stub-focused plugin, then define the intended treatment of Callable[[], None], Callable[[], Any], and Callable[[], object] before implementation and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100