The following issues were found
docs_src/request_files/tutorial002.py
6 issues
Line: 3
Column: 1
from typing import List
from fastapi import FastAPI, File, UploadFile
from fastapi.responses import HTMLResponse
app = FastAPI()
@app.post("/files/")
Reported by Pylint.
Line: 4
Column: 1
from typing import List
from fastapi import FastAPI, File, UploadFile
from fastapi.responses import HTMLResponse
app = FastAPI()
@app.post("/files/")
Reported by Pylint.
Line: 1
Column: 1
from typing import List
from fastapi import FastAPI, File, UploadFile
from fastapi.responses import HTMLResponse
app = FastAPI()
@app.post("/files/")
Reported by Pylint.
Line: 10
Column: 1
@app.post("/files/")
async def create_files(files: List[bytes] = File(...)):
return {"file_sizes": [len(file) for file in files]}
@app.post("/uploadfiles/")
async def create_upload_files(files: List[UploadFile] = File(...)):
Reported by Pylint.
Line: 15
Column: 1
@app.post("/uploadfiles/")
async def create_upload_files(files: List[UploadFile] = File(...)):
return {"filenames": [file.filename for file in files]}
@app.get("/")
async def main():
Reported by Pylint.
Line: 20
Column: 1
@app.get("/")
async def main():
content = """
<body>
<form action="/files/" enctype="multipart/form-data" method="post">
<input name="files" type="file" multiple>
<input type="submit">
Reported by Pylint.
docs_src/body_fields/tutorial001.py
6 issues
Line: 3
Column: 1
from typing import Optional
from fastapi import Body, FastAPI
from pydantic import BaseModel, Field
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 4
Column: 1
from typing import Optional
from fastapi import Body, FastAPI
from pydantic import BaseModel, Field
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 1
Column: 1
from typing import Optional
from fastapi import Body, FastAPI
from pydantic import BaseModel, Field
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 9
Column: 1
app = FastAPI()
class Item(BaseModel):
name: str
description: Optional[str] = Field(
None, title="The description of the item", max_length=300
)
price: float = Field(..., gt=0, description="The price must be greater than zero")
Reported by Pylint.
Line: 9
Column: 1
app = FastAPI()
class Item(BaseModel):
name: str
description: Optional[str] = Field(
None, title="The description of the item", max_length=300
)
price: float = Field(..., gt=0, description="The price must be greater than zero")
Reported by Pylint.
Line: 19
Column: 1
@app.put("/items/{item_id}")
async def update_item(item_id: int, item: Item = Body(..., embed=True)):
results = {"item_id": item_id, "item": item}
return results
Reported by Pylint.
docs_src/body_multiple_params/tutorial005.py
6 issues
Line: 3
Column: 1
from typing import Optional
from fastapi import Body, FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 4
Column: 1
from typing import Optional
from fastapi import Body, FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 1
Column: 1
from typing import Optional
from fastapi import Body, FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 9
Column: 1
app = FastAPI()
class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
tax: Optional[float] = None
Reported by Pylint.
Line: 9
Column: 1
app = FastAPI()
class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
tax: Optional[float] = None
Reported by Pylint.
Line: 17
Column: 1
@app.put("/items/{item_id}")
async def update_item(item_id: int, item: Item = Body(..., embed=True)):
results = {"item_id": item_id, "item": item}
return results
Reported by Pylint.
tests/test_tutorial/test_events/test_tutorial001.py
6 issues
Line: 1
Column: 1
from fastapi.testclient import TestClient
from docs_src.events.tutorial001 import app
openapi_schema = {
"openapi": "3.0.2",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
"/items/{item_id}": {
Reported by Pylint.
Line: 72
Column: 1
}
def test_events():
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
response = client.get("/items/foo")
Reported by Pylint.
Line: 75
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_events():
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
response = client.get("/items/foo")
assert response.status_code == 200, response.text
assert response.json() == {"name": "Fighters"}
Reported by Bandit.
Line: 76
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
response = client.get("/items/foo")
assert response.status_code == 200, response.text
assert response.json() == {"name": "Fighters"}
Reported by Bandit.
Line: 78
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
response = client.get("/items/foo")
assert response.status_code == 200, response.text
assert response.json() == {"name": "Fighters"}
Reported by Bandit.
Line: 79
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert response.json() == openapi_schema
response = client.get("/items/foo")
assert response.status_code == 200, response.text
assert response.json() == {"name": "Fighters"}
Reported by Bandit.
tests/test_tutorial/test_response_headers/test_tutorial001.py
6 issues
Line: 1
Column: 1
from fastapi.testclient import TestClient
from docs_src.response_headers.tutorial001 import app
client = TestClient(app)
def test_path_operation():
response = client.get("/headers/")
Reported by Pylint.
Line: 8
Column: 1
client = TestClient(app)
def test_path_operation():
response = client.get("/headers/")
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert response.headers["X-Cat-Dog"] == "alone in the world"
assert response.headers["Content-Language"] == "en-US"
Reported by Pylint.
Line: 10
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_path_operation():
response = client.get("/headers/")
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert response.headers["X-Cat-Dog"] == "alone in the world"
assert response.headers["Content-Language"] == "en-US"
Reported by Bandit.
Line: 11
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_path_operation():
response = client.get("/headers/")
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert response.headers["X-Cat-Dog"] == "alone in the world"
assert response.headers["Content-Language"] == "en-US"
Reported by Bandit.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
response = client.get("/headers/")
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert response.headers["X-Cat-Dog"] == "alone in the world"
assert response.headers["Content-Language"] == "en-US"
Reported by Bandit.
Line: 13
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert response.headers["X-Cat-Dog"] == "alone in the world"
assert response.headers["Content-Language"] == "en-US"
Reported by Bandit.
docs_src/dependencies/tutorial002.py
6 issues
Line: 3
Column: 1
from typing import Optional
from fastapi import Depends, FastAPI
app = FastAPI()
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
Reported by Pylint.
Line: 1
Column: 1
from typing import Optional
from fastapi import Depends, FastAPI
app = FastAPI()
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
Reported by Pylint.
Line: 11
Column: 1
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
class CommonQueryParams:
def __init__(self, q: Optional[str] = None, skip: int = 0, limit: int = 100):
self.q = q
self.skip = skip
self.limit = limit
Reported by Pylint.
Line: 11
Column: 1
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
class CommonQueryParams:
def __init__(self, q: Optional[str] = None, skip: int = 0, limit: int = 100):
self.q = q
self.skip = skip
self.limit = limit
Reported by Pylint.
Line: 13
Column: 9
class CommonQueryParams:
def __init__(self, q: Optional[str] = None, skip: int = 0, limit: int = 100):
self.q = q
self.skip = skip
self.limit = limit
@app.get("/items/")
Reported by Pylint.
Line: 19
Column: 1
@app.get("/items/")
async def read_items(commons: CommonQueryParams = Depends(CommonQueryParams)):
response = {}
if commons.q:
response.update({"q": commons.q})
items = fake_items_db[commons.skip : commons.skip + commons.limit]
response.update({"items": items})
Reported by Pylint.
docs_src/dependencies/tutorial003.py
6 issues
Line: 3
Column: 1
from typing import Optional
from fastapi import Depends, FastAPI
app = FastAPI()
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
Reported by Pylint.
Line: 1
Column: 1
from typing import Optional
from fastapi import Depends, FastAPI
app = FastAPI()
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
Reported by Pylint.
Line: 11
Column: 1
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
class CommonQueryParams:
def __init__(self, q: Optional[str] = None, skip: int = 0, limit: int = 100):
self.q = q
self.skip = skip
self.limit = limit
Reported by Pylint.
Line: 11
Column: 1
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
class CommonQueryParams:
def __init__(self, q: Optional[str] = None, skip: int = 0, limit: int = 100):
self.q = q
self.skip = skip
self.limit = limit
Reported by Pylint.
Line: 13
Column: 9
class CommonQueryParams:
def __init__(self, q: Optional[str] = None, skip: int = 0, limit: int = 100):
self.q = q
self.skip = skip
self.limit = limit
@app.get("/items/")
Reported by Pylint.
Line: 19
Column: 1
@app.get("/items/")
async def read_items(commons=Depends(CommonQueryParams)):
response = {}
if commons.q:
response.update({"q": commons.q})
items = fake_items_db[commons.skip : commons.skip + commons.limit]
response.update({"items": items})
Reported by Pylint.
tests/test_tutorial/test_response_change_status_code/test_tutorial001.py
6 issues
Line: 1
Column: 1
from fastapi.testclient import TestClient
from docs_src.response_change_status_code.tutorial001 import app
client = TestClient(app)
def test_path_operation():
response = client.put("/get-or-create-task/foo")
Reported by Pylint.
Line: 8
Column: 1
client = TestClient(app)
def test_path_operation():
response = client.put("/get-or-create-task/foo")
print(response.content)
assert response.status_code == 200, response.text
assert response.json() == "Listen to the Bar Fighters"
response = client.put("/get-or-create-task/bar")
Reported by Pylint.
Line: 11
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_path_operation():
response = client.put("/get-or-create-task/foo")
print(response.content)
assert response.status_code == 200, response.text
assert response.json() == "Listen to the Bar Fighters"
response = client.put("/get-or-create-task/bar")
assert response.status_code == 201, response.text
assert response.json() == "This didn't exist before"
Reported by Bandit.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
response = client.put("/get-or-create-task/foo")
print(response.content)
assert response.status_code == 200, response.text
assert response.json() == "Listen to the Bar Fighters"
response = client.put("/get-or-create-task/bar")
assert response.status_code == 201, response.text
assert response.json() == "This didn't exist before"
Reported by Bandit.
Line: 14
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert response.status_code == 200, response.text
assert response.json() == "Listen to the Bar Fighters"
response = client.put("/get-or-create-task/bar")
assert response.status_code == 201, response.text
assert response.json() == "This didn't exist before"
Reported by Bandit.
Line: 15
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert response.json() == "Listen to the Bar Fighters"
response = client.put("/get-or-create-task/bar")
assert response.status_code == 201, response.text
assert response.json() == "This didn't exist before"
Reported by Bandit.
docs_src/body_nested_models/tutorial001.py
6 issues
Line: 3
Column: 1
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 4
Column: 1
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 1
Column: 1
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 9
Column: 1
app = FastAPI()
class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
tax: Optional[float] = None
tags: list = []
Reported by Pylint.
Line: 9
Column: 1
app = FastAPI()
class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
tax: Optional[float] = None
tags: list = []
Reported by Pylint.
Line: 18
Column: 1
@app.put("/items/{item_id}")
async def update_item(item_id: int, item: Item):
results = {"item_id": item_id, "item": item}
return results
Reported by Pylint.
docs_src/body_nested_models/tutorial002.py
6 issues
Line: 3
Column: 1
from typing import List, Optional
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 4
Column: 1
from typing import List, Optional
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 1
Column: 1
from typing import List, Optional
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
Reported by Pylint.
Line: 9
Column: 1
app = FastAPI()
class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
tax: Optional[float] = None
tags: List[str] = []
Reported by Pylint.
Line: 9
Column: 1
app = FastAPI()
class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
tax: Optional[float] = None
tags: List[str] = []
Reported by Pylint.
Line: 18
Column: 1
@app.put("/items/{item_id}")
async def update_item(item_id: int, item: Item):
results = {"item_id": item_id, "item": item}
return results
Reported by Pylint.