The following issues were found

tests/test_tutorial/test_settings/test_app02.py
6 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              from fastapi.testclient import TestClient
from pytest import MonkeyPatch

from docs_src.settings.app02 import main, test_main

client = TestClient(main.app)


def test_settings(monkeypatch: MonkeyPatch):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient
from pytest import MonkeyPatch

from docs_src.settings.app02 import main, test_main

client = TestClient(main.app)


def test_settings(monkeypatch: MonkeyPatch):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              client = TestClient(main.app)


def test_settings(monkeypatch: MonkeyPatch):
    monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com")
    settings = main.get_settings()
    assert settings.app_name == "Awesome API"
    assert settings.items_per_user == 50


            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 12
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              def test_settings(monkeypatch: MonkeyPatch):
    monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com")
    settings = main.get_settings()
    assert settings.app_name == "Awesome API"
    assert settings.items_per_user == 50


def test_override_settings():
    test_main.test_app()

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 13
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com")
    settings = main.get_settings()
    assert settings.app_name == "Awesome API"
    assert settings.items_per_user == 50


def test_override_settings():
    test_main.test_app()

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 16 Column: 1

                  assert settings.items_per_user == 50


def test_override_settings():
    test_main.test_app()

            

Reported by Pylint.

docs_src/bigger_applications/app/main.py
6 issues
Unable to import 'fastapi'
Error

Line: 1 Column: 1

              from fastapi import Depends, FastAPI

from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users

app = FastAPI(dependencies=[Depends(get_query_token)])



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              from fastapi import Depends, FastAPI

from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users

app = FastAPI(dependencies=[Depends(get_query_token)])



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              from fastapi import Depends, FastAPI

from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users

app = FastAPI(dependencies=[Depends(get_query_token)])



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 5 Column: 1

              
from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users

app = FastAPI(dependencies=[Depends(get_query_token)])


app.include_router(users.router)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from fastapi import Depends, FastAPI

from .dependencies import get_query_token, get_token_header
from .internal import admin
from .routers import items, users

app = FastAPI(dependencies=[Depends(get_query_token)])



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 1

              

@app.get("/")
async def root():
    return {"message": "Hello Bigger Applications!"}

            

Reported by Pylint.

tests/test_include_route.py
6 issues
Unused argument 'request'
Error

Line: 10 Column: 16

              

@router.route("/items/")
def read_items(request: Request):
    return JSONResponse({"hello": "world"})


app.include_router(router)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from fastapi import APIRouter, FastAPI, Request
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient

app = FastAPI()
router = APIRouter()


@router.route("/items/")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              

@router.route("/items/")
def read_items(request: Request):
    return JSONResponse({"hello": "world"})


app.include_router(router)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 1

              client = TestClient(app)


def test_sub_router():
    response = client.get("/items/")
    assert response.status_code == 200, response.text
    assert response.json() == {"hello": "world"}

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 21
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              
def test_sub_router():
    response = client.get("/items/")
    assert response.status_code == 200, response.text
    assert response.json() == {"hello": "world"}

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 22
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              def test_sub_router():
    response = client.get("/items/")
    assert response.status_code == 200, response.text
    assert response.json() == {"hello": "world"}

            

Reported by Bandit.

docs_src/body/tutorial001.py
6 issues
Unable to import 'fastapi'
Error

Line: 3 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None

            

Reported by Pylint.

Unable to import 'pydantic'
Error

Line: 4 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 7 Column: 1

              from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None
    price: float
    tax: Optional[float] = None


            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None
    price: float
    tax: Optional[float] = None


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              

@app.post("/items/")
async def create_item(item: Item):
    return item

            

Reported by Pylint.

docs_src/body/tutorial002.py
6 issues
Unable to import 'fastapi'
Error

Line: 3 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None

            

Reported by Pylint.

Unable to import 'pydantic'
Error

Line: 4 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None
    price: float
    tax: Optional[float] = None


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 7 Column: 1

              from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None
    price: float
    tax: Optional[float] = None


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              

@app.post("/items/")
async def create_item(item: Item):
    item_dict = item.dict()
    if item.tax:
        price_with_tax = item.price + item.tax
        item_dict.update({"price_with_tax": price_with_tax})
    return item_dict

            

Reported by Pylint.

docs_src/dependencies/tutorial001.py
6 issues
Unable to import 'fastapi'
Error

Line: 3 Column: 1

              from typing import Optional

from fastapi import Depends, FastAPI

app = FastAPI()


async def common_parameters(q: Optional[str] = None, skip: int = 0, limit: int = 100):
    return {"q": q, "skip": skip, "limit": limit}

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Optional

from fastapi import Depends, FastAPI

app = FastAPI()


async def common_parameters(q: Optional[str] = None, skip: int = 0, limit: int = 100):
    return {"q": q, "skip": skip, "limit": limit}

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              app = FastAPI()


async def common_parameters(q: Optional[str] = None, skip: int = 0, limit: int = 100):
    return {"q": q, "skip": skip, "limit": limit}


@app.get("/items/")
async def read_items(commons: dict = Depends(common_parameters)):

            

Reported by Pylint.

Argument name "q" doesn't conform to snake_case naming style
Error

Line: 8 Column: 1

              app = FastAPI()


async def common_parameters(q: Optional[str] = None, skip: int = 0, limit: int = 100):
    return {"q": q, "skip": skip, "limit": limit}


@app.get("/items/")
async def read_items(commons: dict = Depends(common_parameters)):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              

@app.get("/items/")
async def read_items(commons: dict = Depends(common_parameters)):
    return commons


@app.get("/users/")
async def read_users(commons: dict = Depends(common_parameters)):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              

@app.get("/users/")
async def read_users(commons: dict = Depends(common_parameters)):
    return commons

            

Reported by Pylint.

tests/test_additional_responses_bad.py
6 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient

app = FastAPI()


@app.get("/a", responses={"hello": {"description": "Not a valid additional response"}})
async def a():

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient

app = FastAPI()


@app.get("/a", responses={"hello": {"description": "Not a valid additional response"}})
async def a():

            

Reported by Pylint.

Function name "a" doesn't conform to snake_case naming style
Error

Line: 9 Column: 1

              

@app.get("/a", responses={"hello": {"description": "Not a valid additional response"}})
async def a():
    pass  # pragma: no cover


openapi_schema = {
    "openapi": "3.0.2",

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              

@app.get("/a", responses={"hello": {"description": "Not a valid additional response"}})
async def a():
    pass  # pragma: no cover


openapi_schema = {
    "openapi": "3.0.2",

            

Reported by Pylint.

Line too long (101/100)
Error

Line: 21 Column: 1

                          "get": {
                "responses": {
                    # this is how one would imagine the openapi schema to be
                    # but since the key is not valid, openapi.utils.get_openapi will raise ValueError
                    "hello": {"description": "Not a valid additional response"},
                    "200": {
                        "description": "Successful Response",
                        "content": {"application/json": {"schema": {}}},
                    },

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 38 Column: 1

              client = TestClient(app)


def test_openapi_schema():
    with pytest.raises(ValueError):
        client.get("/openapi.json")

            

Reported by Pylint.

tests/test_operations_signatures.py
6 issues
Missing module docstring
Error

Line: 1 Column: 1

              import inspect

from fastapi import APIRouter, FastAPI

method_names = ["get", "put", "post", "delete", "options", "head", "patch", "trace"]


def test_signatures_consistency():
    base_sig = inspect.signature(APIRouter.get)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              method_names = ["get", "put", "post", "delete", "options", "head", "patch", "trace"]


def test_signatures_consistency():
    base_sig = inspect.signature(APIRouter.get)
    for method_name in method_names:
        router_method = getattr(APIRouter, method_name)
        app_method = getattr(FastAPI, method_name)
        router_sig = inspect.signature(router_method)

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 19
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      for key, param in base_sig.parameters.items():
            router_param: inspect.Parameter = router_sig.parameters[key]
            app_param: inspect.Parameter = app_sig.parameters[key]
            assert param.annotation == router_param.annotation
            assert param.annotation == app_param.annotation
            assert param.default == router_param.default
            assert param.default == app_param.default

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 20
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                          router_param: inspect.Parameter = router_sig.parameters[key]
            app_param: inspect.Parameter = app_sig.parameters[key]
            assert param.annotation == router_param.annotation
            assert param.annotation == app_param.annotation
            assert param.default == router_param.default
            assert param.default == app_param.default

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 21
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                          app_param: inspect.Parameter = app_sig.parameters[key]
            assert param.annotation == router_param.annotation
            assert param.annotation == app_param.annotation
            assert param.default == router_param.default
            assert param.default == app_param.default

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 22
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                          assert param.annotation == router_param.annotation
            assert param.annotation == app_param.annotation
            assert param.default == router_param.default
            assert param.default == app_param.default

            

Reported by Bandit.

docs_src/body/tutorial003.py
6 issues
Unable to import 'fastapi'
Error

Line: 3 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None

            

Reported by Pylint.

Unable to import 'pydantic'
Error

Line: 4 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None
    price: float
    tax: Optional[float] = None


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 7 Column: 1

              from pydantic import BaseModel


class Item(BaseModel):
    name: str
    description: Optional[str] = None
    price: float
    tax: Optional[float] = None


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              

@app.put("/items/{item_id}")
async def create_item(item_id: int, item: Item):
    return {"item_id": item_id, **item.dict()}

            

Reported by Pylint.

docs_src/schema_extra_example/tutorial003.py
6 issues
Unable to import 'fastapi'
Error

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.

Unable to import 'pydantic'
Error

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.

Missing module docstring
Error

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.

Missing class docstring
Error

Line: 9 Column: 1

              app = FastAPI()


class Item(BaseModel):
    name: str
    description: Optional[str] = None
    price: float
    tax: Optional[float] = None


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 9 Column: 1

              app = FastAPI()


class Item(BaseModel):
    name: str
    description: Optional[str] = None
    price: float
    tax: Optional[float] = None


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              

@app.put("/items/{item_id}")
async def update_item(
    item_id: int,
    item: Item = Body(
        ...,
        example={
            "name": "Foo",

            

Reported by Pylint.