Add truthy-coroutine check
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
async def func() -> bool:
return True
async def func2() -> None:
if func():
print("hi")
In this code, a likely fix is to change func() to await func(). Meanwhile, it'll always be true since a Coroutine is always true. The truthy-bool check could flag it but it's not enabled by default. We can add a new truthy-coroutine check (like truthy-function) for the specific case of using a Coroutine in boolean context.
The error message can suggest that an await might've been mistakenly omitted.
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
Start by comparing the existing truthy-bool and truthy-function checks, then trace how a Coroutine is handled in boolean context. Add a truthy-coroutine diagnostic for the shown async example, with a message suggesting that await may be missing, and verify the check's behavior against equivalent coroutine and non-coroutine cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100