Ir al contenido

Route handler naming (ARCH2004)

Esta página aún no está disponible en tu idioma.

Key python.naming.route-handler-naming · Severity info · Category naming

Web framework route handler names should match the semantics of the HTTP verb they serve (GET → get/list, POST → create). Mismatched naming breaks RESTful consistency and makes the code misleading.

@app.post("/users")
def get_users(payload): # POST but named 'get'
return create_user(payload)
@app.post("/users")
def create_user(payload):
return save_user(payload)

Name the handler after its HTTP verb (GET → get/list, POST → create, PUT → update, DELETE → delete).