The following issues were found
tests/test_tutorial/test_custom_response/test_tutorial009b.py
3 issues
Line: 1
Column: 1
from pathlib import Path
from fastapi.testclient import TestClient
from docs_src.custom_response import tutorial009b
from docs_src.custom_response.tutorial009b import app
client = TestClient(app)
Reported by Pylint.
Line: 11
Column: 1
client = TestClient(app)
def test_get(tmp_path: Path):
file_path: Path = tmp_path / "large-video-file.mp4"
tutorial009b.some_file_path = str(file_path)
test_content = b"Fake video bytes"
file_path.write_bytes(test_content)
response = client.get("/")
Reported by Pylint.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
test_content = b"Fake video bytes"
file_path.write_bytes(test_content)
response = client.get("/")
assert response.content == test_content
Reported by Bandit.
docs_src/extra_data_types/tutorial001.py
3 issues
Line: 5
Column: 1
from typing import Optional
from uuid import UUID
from fastapi import Body, FastAPI
app = FastAPI()
@app.put("/items/{item_id}")
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime, time, timedelta
from typing import Optional
from uuid import UUID
from fastapi import Body, FastAPI
app = FastAPI()
Reported by Pylint.
Line: 11
Column: 1
@app.put("/items/{item_id}")
async def read_items(
item_id: UUID,
start_datetime: Optional[datetime] = Body(None),
end_datetime: Optional[datetime] = Body(None),
repeat_at: Optional[time] = Body(None),
process_after: Optional[timedelta] = Body(None),
Reported by Pylint.
docs_src/extra_models/tutorial005.py
3 issues
Line: 3
Column: 1
from typing import Dict
from fastapi import FastAPI
app = FastAPI()
@app.get("/keyword-weights/", response_model=Dict[str, float])
async def read_keyword_weights():
Reported by Pylint.
Line: 1
Column: 1
from typing import Dict
from fastapi import FastAPI
app = FastAPI()
@app.get("/keyword-weights/", response_model=Dict[str, float])
async def read_keyword_weights():
Reported by Pylint.
Line: 9
Column: 1
@app.get("/keyword-weights/", response_model=Dict[str, float])
async def read_keyword_weights():
return {"foo": 2.3, "bar": 3.4}
Reported by Pylint.
docs_src/first_steps/tutorial001.py
3 issues
Line: 1
Column: 1
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
Reported by Pylint.
Line: 1
Column: 1
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
Reported by Pylint.
Line: 7
Column: 1
@app.get("/")
async def root():
return {"message": "Hello World"}
Reported by Pylint.
docs_src/first_steps/tutorial002.py
3 issues
Line: 1
Column: 1
from fastapi import FastAPI
my_awesome_api = FastAPI()
@my_awesome_api.get("/")
async def root():
return {"message": "Hello World"}
Reported by Pylint.
Line: 1
Column: 1
from fastapi import FastAPI
my_awesome_api = FastAPI()
@my_awesome_api.get("/")
async def root():
return {"message": "Hello World"}
Reported by Pylint.
Line: 7
Column: 1
@my_awesome_api.get("/")
async def root():
return {"message": "Hello World"}
Reported by Pylint.
docs_src/first_steps/tutorial003.py
3 issues
Line: 1
Column: 1
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"message": "Hello World"}
Reported by Pylint.
Line: 1
Column: 1
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"message": "Hello World"}
Reported by Pylint.
Line: 7
Column: 1
@app.get("/")
def root():
return {"message": "Hello World"}
Reported by Pylint.
docs_src/handling_errors/tutorial001.py
3 issues
Line: 1
Column: 1
from fastapi import FastAPI, HTTPException
app = FastAPI()
items = {"foo": "The Foo Wrestlers"}
@app.get("/items/{item_id}")
async def read_item(item_id: str):
Reported by Pylint.
Line: 1
Column: 1
from fastapi import FastAPI, HTTPException
app = FastAPI()
items = {"foo": "The Foo Wrestlers"}
@app.get("/items/{item_id}")
async def read_item(item_id: str):
Reported by Pylint.
Line: 9
Column: 1
@app.get("/items/{item_id}")
async def read_item(item_id: str):
if item_id not in items:
raise HTTPException(status_code=404, detail="Item not found")
return {"item": items[item_id]}
Reported by Pylint.
docs_src/handling_errors/tutorial002.py
3 issues
Line: 1
Column: 1
from fastapi import FastAPI, HTTPException
app = FastAPI()
items = {"foo": "The Foo Wrestlers"}
@app.get("/items-header/{item_id}")
async def read_item_header(item_id: str):
Reported by Pylint.
Line: 1
Column: 1
from fastapi import FastAPI, HTTPException
app = FastAPI()
items = {"foo": "The Foo Wrestlers"}
@app.get("/items-header/{item_id}")
async def read_item_header(item_id: str):
Reported by Pylint.
Line: 9
Column: 1
@app.get("/items-header/{item_id}")
async def read_item_header(item_id: str):
if item_id not in items:
raise HTTPException(
status_code=404,
detail="Item not found",
headers={"X-Error": "There goes my error"},
Reported by Pylint.
docs_src/behind_a_proxy/tutorial003.py
3 issues
Line: 1
Column: 1
from fastapi import FastAPI, Request
app = FastAPI(
servers=[
{"url": "https://stag.example.com", "description": "Staging environment"},
{"url": "https://prod.example.com", "description": "Production environment"},
],
root_path="/api/v1",
)
Reported by Pylint.
Line: 1
Column: 1
from fastapi import FastAPI, Request
app = FastAPI(
servers=[
{"url": "https://stag.example.com", "description": "Staging environment"},
{"url": "https://prod.example.com", "description": "Production environment"},
],
root_path="/api/v1",
)
Reported by Pylint.
Line: 13
Column: 1
@app.get("/app")
def read_main(request: Request):
return {"message": "Hello World", "root_path": request.scope.get("root_path")}
Reported by Pylint.
docs_src/header_params/tutorial001.py
3 issues
Line: 3
Column: 1
from typing import Optional
from fastapi import FastAPI, Header
app = FastAPI()
@app.get("/items/")
async def read_items(user_agent: Optional[str] = Header(None)):
Reported by Pylint.
Line: 1
Column: 1
from typing import Optional
from fastapi import FastAPI, Header
app = FastAPI()
@app.get("/items/")
async def read_items(user_agent: Optional[str] = Header(None)):
Reported by Pylint.
Line: 9
Column: 1
@app.get("/items/")
async def read_items(user_agent: Optional[str] = Header(None)):
return {"User-Agent": user_agent}
Reported by Pylint.