High Python

Use async/await for I/O operations

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.

Included in Rulesets

Django Best Practices
36 rules • 1 standard
View
FastAPI Guidelines
36 rules • 1 standard
View
Python Standards
33 rules • 2 standards
View
Code Review Standards
58 rules • 0 standards
View

Add This Rule

Sign in to add this rule to your workspace

Sign in with GitHub

Details

Severity
High
Category
Python
Used in
4 rulesets