Kludex / Kludex/flake8-fastapi

Rules

Open
#1 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
46
Forks
4
PR merge metrics
No merged PRs in 30d

Description

I'll use this issue to create the rules.

I still need to think about them, but I'll try to update it here. Once I have a nice set of rules, I'm going to implement them.

### Rules

#### Trial

**CF003** - `responses` parameter is empty but exceptions are being raised.
**CF005** - `PositiveInt`, `NegativeInt`, and `gt`, `lt` parameters should be avoided due to incompatibility between JSON schema version used by Pydantic and OpenAPI version used by Swagger-UI on FastAPI.
**CF006** - Repeated endpoint function name.
**CF007** - Endpoint order matters.
**CF010** - Unused `APIRouter` object.
**CF012** - Include `APIRouter` multiple times.
**CF013** - Should not use mutable object in dependency e.g. `Potato()` - as it cannot be overridden.
**CF014** - Dependencies that are not async, but are very short and don't need to run on the ThreadPoolExecutor.

#### Implemented

**CF001** - `@app.route` usage with `methods` parameter, instead of specific method decorator.
**CF002** - `prefix` parameter should be avoided on `include_router`, instead it should be used in the `Router` constructor.
**CF004** - Using `exception_handler` for `Exception` is not possible.
**CF008** - CORSMiddleware order matters.
**CF009** - Check if `HTTPException` is being documented.
**CF011** - Use `Response` on 204 endpoints.

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the unfinished Trial rules and the separate Implemented list to understand the intended scope. No files, tests, or entry points are named in the issue, so repository exploration is required; done means agreeing on the remaining rule scope and implementing and verifying it consistently with the existing checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.