High
Python
Use async/await for I/O operations
Official
Rule Description
Use async/await for I/O-bound operations:
- HTTP requests (use httpx or aiohttp)
- Database queries (use asyncpg, databases)
- File operations (use aiofiles)
```python
import httpx
async def fetch_users() -> list[User]:
async with httpx.AsyncClient() as client:
response = await client.get("https://api.example.com/users")
return [User(**u) for u in response.json()]
```
Don't mix sync and async code - choose one paradigm per service.
Add This Rule
Sign in to add this rule to your workspace
Sign in with GitHubDetails
- Severity
- High
- Category
- Python
- Used in
- 4 rulesets