The following issues were found

docs_src/settings/app02/test_main.py
7 issues
Unable to import 'fastapi.testclient'
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from .config import Settings
from .main import app, get_settings

client = TestClient(app)


def get_settings_override():

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              from fastapi.testclient import TestClient

from .config import Settings
from .main import app, get_settings

client = TestClient(app)


def get_settings_override():

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              from fastapi.testclient import TestClient

from .config import Settings
from .main import app, get_settings

client = TestClient(app)


def get_settings_override():

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from .config import Settings
from .main import app, get_settings

client = TestClient(app)


def get_settings_override():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              client = TestClient(app)


def get_settings_override():
    return Settings(admin_email="testing_admin@example.com")


app.dependency_overrides[get_settings] = get_settings_override


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 1

              app.dependency_overrides[get_settings] = get_settings_override


def test_app():
    response = client.get("/info")
    data = response.json()
    assert data == {
        "app_name": "Awesome API",
        "admin_email": "testing_admin@example.com",

            

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

              def test_app():
    response = client.get("/info")
    data = response.json()
    assert data == {
        "app_name": "Awesome API",
        "admin_email": "testing_admin@example.com",
        "items_per_user": 50,
    }

            

Reported by Bandit.

fastapi/websockets.py
7 issues
Unable to import 'starlette.websockets'
Error

Line: 1 Column: 1

              from starlette.websockets import WebSocket as WebSocket  # noqa
from starlette.websockets import WebSocketDisconnect as WebSocketDisconnect  # noqa

            

Reported by Pylint.

Unable to import 'starlette.websockets'
Error

Line: 2 Column: 1

              from starlette.websockets import WebSocket as WebSocket  # noqa
from starlette.websockets import WebSocketDisconnect as WebSocketDisconnect  # noqa

            

Reported by Pylint.

Unused WebSocket imported from starlette.websockets as WebSocket
Error

Line: 1 Column: 1

              from starlette.websockets import WebSocket as WebSocket  # noqa
from starlette.websockets import WebSocketDisconnect as WebSocketDisconnect  # noqa

            

Reported by Pylint.

Unused WebSocketDisconnect imported from starlette.websockets as WebSocketDisconnect
Error

Line: 2 Column: 1

              from starlette.websockets import WebSocket as WebSocket  # noqa
from starlette.websockets import WebSocketDisconnect as WebSocketDisconnect  # noqa

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from starlette.websockets import WebSocket as WebSocket  # noqa
from starlette.websockets import WebSocketDisconnect as WebSocketDisconnect  # noqa

            

Reported by Pylint.

Import alias does not rename original package
Error

Line: 1 Column: 1

              from starlette.websockets import WebSocket as WebSocket  # noqa
from starlette.websockets import WebSocketDisconnect as WebSocketDisconnect  # noqa

            

Reported by Pylint.

Import alias does not rename original package
Error

Line: 2 Column: 1

              from starlette.websockets import WebSocket as WebSocket  # noqa
from starlette.websockets import WebSocketDisconnect as WebSocketDisconnect  # noqa

            

Reported by Pylint.

tests/test_repeated_cookie_headers.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi import Depends, FastAPI, Response
from fastapi.testclient import TestClient

app = FastAPI()


def set_cookie(*, response: Response):
    response.set_cookie("cookie-name", "cookie-value")
    return {}

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              app = FastAPI()


def set_cookie(*, response: Response):
    response.set_cookie("cookie-name", "cookie-value")
    return {}


def set_indirect_cookie(*, dep: str = Depends(set_cookie)):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

                  return {}


def set_indirect_cookie(*, dep: str = Depends(set_cookie)):
    return dep


@app.get("/directCookie")
def get_direct_cookie(dep: str = Depends(set_cookie)):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              

@app.get("/directCookie")
def get_direct_cookie(dep: str = Depends(set_cookie)):
    return {"dep": dep}


@app.get("/indirectCookie")
def get_indirect_cookie(dep: str = Depends(set_indirect_cookie)):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 1

              

@app.get("/indirectCookie")
def get_indirect_cookie(dep: str = Depends(set_indirect_cookie)):
    return {"dep": dep}


client = TestClient(app)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 29 Column: 1

              client = TestClient(app)


def test_cookie_is_set_once():
    direct_response = client.get("/directCookie")
    indirect_response = client.get("/indirectCookie")
    assert (
        direct_response.headers["set-cookie"] == indirect_response.headers["set-cookie"]
    )

            

Reported by Pylint.

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

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

              def test_cookie_is_set_once():
    direct_response = client.get("/directCookie")
    indirect_response = client.get("/indirectCookie")
    assert (
        direct_response.headers["set-cookie"] == indirect_response.headers["set-cookie"]
    )

            

Reported by Bandit.

tests/test_response_change_status_code.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi import Depends, FastAPI, Response
from fastapi.testclient import TestClient

app = FastAPI()


async def response_status_setter(response: Response):
    response.status_code = 201


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              app = FastAPI()


async def response_status_setter(response: Response):
    response.status_code = 201


async def parent_dep(result=Depends(response_status_setter)):
    return result

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

                  response.status_code = 201


async def parent_dep(result=Depends(response_status_setter)):
    return result


@app.get("/", dependencies=[Depends(parent_dep)])
async def get_main():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 1

              

@app.get("/", dependencies=[Depends(parent_dep)])
async def get_main():
    return {"msg": "Hello World"}


client = TestClient(app)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 1

              client = TestClient(app)


def test_dependency_set_status_code():
    response = client.get("/")
    assert response.status_code == 201, response.text
    assert response.json() == {"msg": "Hello World"}

            

Reported by Pylint.

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

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

              
def test_dependency_set_status_code():
    response = client.get("/")
    assert response.status_code == 201, response.text
    assert response.json() == {"msg": "Hello World"}

            

Reported by Bandit.

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

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

              def test_dependency_set_status_code():
    response = client.get("/")
    assert response.status_code == 201, response.text
    assert response.json() == {"msg": "Hello World"}

            

Reported by Bandit.

tests/test_router_prefix_with_template.py
7 issues
Redefining built-in 'id'
Error

Line: 10 Column: 29

              

@router.get("/users/{id}")
def read_user(segment: str, id: str):
    return {"segment": segment, "id": id}


app.include_router(router, prefix="/{segment}")


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient

app = FastAPI()

router = APIRouter()


@router.get("/users/{id}")

            

Reported by Pylint.

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

Line: 10 Column: 1

              

@router.get("/users/{id}")
def read_user(segment: str, id: str):
    return {"segment": segment, "id": id}


app.include_router(router, prefix="/{segment}")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              

@router.get("/users/{id}")
def read_user(segment: str, id: str):
    return {"segment": segment, "id": id}


app.include_router(router, prefix="/{segment}")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

              client = TestClient(app)


def test_get():
    response = client.get("/seg/users/foo")
    assert response.status_code == 200, response.text
    assert response.json() == {"segment": "seg", "id": "foo"}

            

Reported by Pylint.

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_get():
    response = client.get("/seg/users/foo")
    assert response.status_code == 200, response.text
    assert response.json() == {"segment": "seg", "id": "foo"}

            

Reported by Bandit.

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

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

              def test_get():
    response = client.get("/seg/users/foo")
    assert response.status_code == 200, response.text
    assert response.json() == {"segment": "seg", "id": "foo"}

            

Reported by Bandit.

tests/test_tutorial/test_additional_status_codes/test_tutorial001.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.additional_status_codes.tutorial001 import app

client = TestClient(app)


def test_update():
    response = client.put("/items/foo", json={"name": "Wrestlers"})

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              client = TestClient(app)


def test_update():
    response = client.put("/items/foo", json={"name": "Wrestlers"})
    assert response.status_code == 200, response.text
    assert response.json() == {"name": "Wrestlers", "size": None}



            

Reported by Pylint.

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

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

              
def test_update():
    response = client.put("/items/foo", json={"name": "Wrestlers"})
    assert response.status_code == 200, response.text
    assert response.json() == {"name": "Wrestlers", "size": None}


def test_create():
    response = client.put("/items/red", json={"name": "Chillies"})

            

Reported by Bandit.

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

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

              def test_update():
    response = client.put("/items/foo", json={"name": "Wrestlers"})
    assert response.status_code == 200, response.text
    assert response.json() == {"name": "Wrestlers", "size": None}


def test_create():
    response = client.put("/items/red", json={"name": "Chillies"})
    assert response.status_code == 201, response.text

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 14 Column: 1

                  assert response.json() == {"name": "Wrestlers", "size": None}


def test_create():
    response = client.put("/items/red", json={"name": "Chillies"})
    assert response.status_code == 201, response.text
    assert response.json() == {"name": "Chillies", "size": None}

            

Reported by Pylint.

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

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

              
def test_create():
    response = client.put("/items/red", json={"name": "Chillies"})
    assert response.status_code == 201, response.text
    assert response.json() == {"name": "Chillies", "size": None}

            

Reported by Bandit.

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

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

              def test_create():
    response = client.put("/items/red", json={"name": "Chillies"})
    assert response.status_code == 201, response.text
    assert response.json() == {"name": "Chillies", "size": None}

            

Reported by Bandit.

tests/test_tutorial/test_behind_a_proxy/test_tutorial001.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.behind_a_proxy.tutorial001 import app

client = TestClient(app, root_path="/api/v1")

openapi_schema = {
    "openapi": "3.0.2",
    "info": {"title": "FastAPI", "version": "0.1.0"},

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

              }


def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema



            

Reported by Pylint.

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

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

              
def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")

            

Reported by Bandit.

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

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

              def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")
    assert response.status_code == 200

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 34 Column: 1

                  assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Pylint.

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

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

              
def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Bandit.

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

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

              def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Bandit.

tests/test_tutorial/test_behind_a_proxy/test_tutorial002.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.behind_a_proxy.tutorial002 import app

client = TestClient(app)

openapi_schema = {
    "openapi": "3.0.2",
    "info": {"title": "FastAPI", "version": "0.1.0"},

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

              }


def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema



            

Reported by Pylint.

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

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

              
def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")

            

Reported by Bandit.

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

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

              def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")
    assert response.status_code == 200

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 34 Column: 1

                  assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Pylint.

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

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

              
def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Bandit.

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

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

              def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Bandit.

tests/test_tutorial/test_behind_a_proxy/test_tutorial003.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.behind_a_proxy.tutorial003 import app

client = TestClient(app)

openapi_schema = {
    "openapi": "3.0.2",
    "info": {"title": "FastAPI", "version": "0.1.0"},

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 32 Column: 1

              }


def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema



            

Reported by Pylint.

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

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

              
def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")

            

Reported by Bandit.

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

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

              def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")
    assert response.status_code == 200

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 38 Column: 1

                  assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Pylint.

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

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

              
def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Bandit.

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

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

              def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Bandit.

tests/test_tutorial/test_behind_a_proxy/test_tutorial004.py
7 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.behind_a_proxy.tutorial004 import app

client = TestClient(app)

openapi_schema = {
    "openapi": "3.0.2",
    "info": {"title": "FastAPI", "version": "0.1.0"},

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 1

              }


def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema



            

Reported by Pylint.

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

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

              
def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")

            

Reported by Bandit.

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

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

              def test_openapi():
    response = client.get("/openapi.json")
    assert response.status_code == 200
    assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")
    assert response.status_code == 200

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 37 Column: 1

                  assert response.json() == openapi_schema


def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Pylint.

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

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

              
def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Bandit.

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

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

              def test_main():
    response = client.get("/app")
    assert response.status_code == 200
    assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}

            

Reported by Bandit.