Skip to content

Commit 524a6a0

Browse files
committed
chore(python): use a constant for 404 status code
1 parent 3b9b22f commit 524a6a0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/python/fastapi/postgres/routes.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def get_v1_categories_count(conn=Depends(db_connection)):
1616
cur.execute("SELECT COUNT(*) AS counter FROM categories")
1717
result = cur.fetchone()
1818
if result is None:
19-
raise HTTPException(status_code=404)
19+
raise HTTPException(status_code = status.HTTP_404_NOT_FOUND)
2020
return result
2121
finally:
2222
conn.close()
@@ -56,7 +56,7 @@ def get_v1_collections_collection_id_categories_count(collectionId, conn=Depends
5656
""", {"collectionId": collectionId})
5757
result = cur.fetchone()
5858
if result is None:
59-
raise HTTPException(status_code=404)
59+
raise HTTPException(status_code = status.HTTP_404_NOT_FOUND)
6060
return result
6161
finally:
6262
conn.close()
@@ -102,7 +102,7 @@ def get_v1_categories_category_id(categoryId, conn=Depends(db_connection)):
102102
""", {"categoryId": categoryId})
103103
result = cur.fetchone()
104104
if result is None:
105-
raise HTTPException(status_code=404)
105+
raise HTTPException(status_code = status.HTTP_404_NOT_FOUND)
106106
return result
107107
finally:
108108
conn.close()

src/templates/routes.py.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def <%- pythonMethodName %>(<%- methodArgs.join(', ') %>):
102102
cur.execute(<%- query.sql %><%- query.formattedParams %>)
103103
result = cur.fetchone()
104104
if result is None:
105-
raise HTTPException(status_code=404)
105+
raise HTTPException(status_code = status.HTTP_404_NOT_FOUND)
106106
return result
107107
<% }
108108
} else {

0 commit comments

Comments
 (0)