The following issues were found

tests/test_tutorial/test_additional_responses/test_tutorial002.py
11 issues
Missing module docstring
Error

Line: 1 Column: 1

              import os
import shutil

from fastapi.testclient import TestClient

from docs_src.additional_responses.tutorial002 import app

client = TestClient(app)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 97 Column: 1

              }


def test_openapi_schema():
    response = client.get("/openapi.json")
    assert response.status_code == 200, response.text
    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: 99
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

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


def test_path_operation():
    response = client.get("/items/foo")

            

Reported by Bandit.

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

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

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


def test_path_operation():
    response = client.get("/items/foo")
    assert response.status_code == 200, response.text

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 103 Column: 1

                  assert response.json() == openapi_schema


def test_path_operation():
    response = client.get("/items/foo")
    assert response.status_code == 200, response.text
    assert response.json() == {"id": "foo", "value": "there goes my hero"}



            

Reported by Pylint.

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

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

              
def test_path_operation():
    response = client.get("/items/foo")
    assert response.status_code == 200, response.text
    assert response.json() == {"id": "foo", "value": "there goes my hero"}


def test_path_operation_img():
    shutil.copy("./docs/en/docs/img/favicon.png", "./image.png")

            

Reported by Bandit.

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

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

              def test_path_operation():
    response = client.get("/items/foo")
    assert response.status_code == 200, response.text
    assert response.json() == {"id": "foo", "value": "there goes my hero"}


def test_path_operation_img():
    shutil.copy("./docs/en/docs/img/favicon.png", "./image.png")
    response = client.get("/items/foo?img=1")

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 109 Column: 1

                  assert response.json() == {"id": "foo", "value": "there goes my hero"}


def test_path_operation_img():
    shutil.copy("./docs/en/docs/img/favicon.png", "./image.png")
    response = client.get("/items/foo?img=1")
    assert response.status_code == 200, response.text
    assert response.headers["Content-Type"] == "image/png"
    assert len(response.content)

            

Reported by Pylint.

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

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

              def test_path_operation_img():
    shutil.copy("./docs/en/docs/img/favicon.png", "./image.png")
    response = client.get("/items/foo?img=1")
    assert response.status_code == 200, response.text
    assert response.headers["Content-Type"] == "image/png"
    assert len(response.content)
    os.remove("./image.png")

            

Reported by Bandit.

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

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

                  shutil.copy("./docs/en/docs/img/favicon.png", "./image.png")
    response = client.get("/items/foo?img=1")
    assert response.status_code == 200, response.text
    assert response.headers["Content-Type"] == "image/png"
    assert len(response.content)
    os.remove("./image.png")

            

Reported by Bandit.

tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py
11 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.openapi_callbacks.tutorial001 import app, invoice_notification

client = TestClient(app)

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

            

Reported by Pylint.

Line too long (518/100)
Error

Line: 14 Column: 1

                      "/invoices/": {
            "post": {
                "summary": "Create Invoice",
                "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n    * At this point is that the API will somehow send a POST request to the\n        external API with the notification of the invoice event\n        (e.g. "payment successful").',
                "operationId": "create_invoice_invoices__post",
                "parameters": [
                    {
                        "required": False,
                        "schema": {

            

Reported by Pylint.

Line too long (118/100)
Error

Line: 59 Column: 1

                                      "{$callback_url}/invoices/{$request.body.id}": {
                            "post": {
                                "summary": "Invoice Notification",
                                "operationId": "invoice_notification__callback_url__invoices___request_body_id__post",
                                "requestBody": {
                                    "required": True,
                                    "content": {
                                        "application/json": {
                                            "schema": {

            

Reported by Pylint.

Line too long (103/100)
Error

Line: 76 Column: 1

                                                      "content": {
                                            "application/json": {
                                                "schema": {
                                                    "$ref": "#/components/schemas/InvoiceEventReceived"
                                                }
                                            }
                                        },
                                    },
                                    "422": {

            

Reported by Pylint.

Line too long (102/100)
Error

Line: 86 Column: 1

                                                      "content": {
                                            "application/json": {
                                                "schema": {
                                                    "$ref": "#/components/schemas/HTTPValidationError"
                                                }
                                            }
                                        },
                                    },
                                },

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 157 Column: 1

              }


def test_openapi():
    with client:
        response = client.get("/openapi.json")

        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: 161
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  with client:
        response = client.get("/openapi.json")

        assert response.json() == openapi_schema


def test_get():
    response = client.post(
        "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 164 Column: 1

                      assert response.json() == openapi_schema


def test_get():
    response = client.post(
        "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
    )
    assert response.status_code == 200, response.text
    assert response.json() == {"msg": "Invoice received"}

            

Reported by Pylint.

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

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

                  response = client.post(
        "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
    )
    assert response.status_code == 200, response.text
    assert response.json() == {"msg": "Invoice received"}


def test_dummy_callback():
    # Just for coverage

            

Reported by Bandit.

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

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

                      "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
    )
    assert response.status_code == 200, response.text
    assert response.json() == {"msg": "Invoice received"}


def test_dummy_callback():
    # Just for coverage
    invoice_notification({})

            

Reported by Bandit.

tests/test_validate_response_dataclass.py
11 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              from typing import List, Optional

import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import ValidationError
from pydantic.dataclasses import dataclass

app = FastAPI()

            

Reported by Pylint.

Unable to import 'pydantic'
Error

Line: 6 Column: 1

              import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import ValidationError
from pydantic.dataclasses import dataclass

app = FastAPI()



            

Reported by Pylint.

Unable to import 'pydantic.dataclasses'
Error

Line: 7 Column: 1

              from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import ValidationError
from pydantic.dataclasses import dataclass

app = FastAPI()


@dataclass

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import List, Optional

import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import ValidationError
from pydantic.dataclasses import dataclass

app = FastAPI()

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              

@dataclass
class Item:
    name: str
    price: Optional[float] = None
    owner_ids: Optional[List[int]] = None



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

              

@app.get("/items/invalid", response_model=Item)
def get_invalid():
    return {"name": "invalid", "price": "foo"}


@app.get("/items/innerinvalid", response_model=Item)
def get_innerinvalid():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 1

              

@app.get("/items/innerinvalid", response_model=Item)
def get_innerinvalid():
    return {"name": "double invalid", "price": "foo", "owner_ids": ["foo", "bar"]}


@app.get("/items/invalidlist", response_model=List[Item])
def get_invalidlist():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 1

              

@app.get("/items/invalidlist", response_model=List[Item])
def get_invalidlist():
    return [
        {"name": "foo"},
        {"name": "bar", "price": "bar"},
        {"name": "baz", "price": "baz"},
    ]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 1

              client = TestClient(app)


def test_invalid():
    with pytest.raises(ValidationError):
        client.get("/items/invalid")


def test_double_invalid():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 1

                      client.get("/items/invalid")


def test_double_invalid():
    with pytest.raises(ValidationError):
        client.get("/items/innerinvalid")


def test_invalid_list():

            

Reported by Pylint.

docs_src/additional_responses/tutorial003.py
10 issues
Unable to import 'fastapi'
Error

Line: 1 Column: 1

              from fastapi import FastAPI
from fastapi.responses import JSONResponse
from pydantic import BaseModel


class Item(BaseModel):
    id: str
    value: str


            

Reported by Pylint.

Unable to import 'fastapi.responses'
Error

Line: 2 Column: 1

              from fastapi import FastAPI
from fastapi.responses import JSONResponse
from pydantic import BaseModel


class Item(BaseModel):
    id: str
    value: str


            

Reported by Pylint.

Unable to import 'pydantic'
Error

Line: 3 Column: 1

              from fastapi import FastAPI
from fastapi.responses import JSONResponse
from pydantic import BaseModel


class Item(BaseModel):
    id: str
    value: str


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from fastapi import FastAPI
from fastapi.responses import JSONResponse
from pydantic import BaseModel


class Item(BaseModel):
    id: str
    value: str


            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              from pydantic import BaseModel


class Item(BaseModel):
    id: str
    value: str


class Message(BaseModel):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 6 Column: 1

              from pydantic import BaseModel


class Item(BaseModel):
    id: str
    value: str


class Message(BaseModel):

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

                  value: str


class Message(BaseModel):
    message: str


app = FastAPI()


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 11 Column: 1

                  value: str


class Message(BaseModel):
    message: str


app = FastAPI()


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

                          "content": {
                "application/json": {
                    "example": {"id": "bar", "value": "The bar tenders"}
                }
            },
        },
    },
)
async def read_item(item_id: str):

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 34 Column: 5

                  },
)
async def read_item(item_id: str):
    if item_id == "foo":
        return {"id": "foo", "value": "there goes my hero"}
    else:
        return JSONResponse(status_code=404, content={"message": "Item not found"})

            

Reported by Pylint.

docs_src/handling_errors/tutorial004.py
10 issues
Unable to import 'fastapi'
Error

Line: 1 Column: 1

              from fastapi import FastAPI, HTTPException
from fastapi.exceptions import RequestValidationError
from fastapi.responses import PlainTextResponse
from starlette.exceptions import HTTPException as StarletteHTTPException

app = FastAPI()


@app.exception_handler(StarletteHTTPException)

            

Reported by Pylint.

Unable to import 'fastapi.exceptions'
Error

Line: 2 Column: 1

              from fastapi import FastAPI, HTTPException
from fastapi.exceptions import RequestValidationError
from fastapi.responses import PlainTextResponse
from starlette.exceptions import HTTPException as StarletteHTTPException

app = FastAPI()


@app.exception_handler(StarletteHTTPException)

            

Reported by Pylint.

Unable to import 'fastapi.responses'
Error

Line: 3 Column: 1

              from fastapi import FastAPI, HTTPException
from fastapi.exceptions import RequestValidationError
from fastapi.responses import PlainTextResponse
from starlette.exceptions import HTTPException as StarletteHTTPException

app = FastAPI()


@app.exception_handler(StarletteHTTPException)

            

Reported by Pylint.

Unable to import 'starlette.exceptions'
Error

Line: 4 Column: 1

              from fastapi import FastAPI, HTTPException
from fastapi.exceptions import RequestValidationError
from fastapi.responses import PlainTextResponse
from starlette.exceptions import HTTPException as StarletteHTTPException

app = FastAPI()


@app.exception_handler(StarletteHTTPException)

            

Reported by Pylint.

Unused argument 'request'
Error

Line: 10 Column: 34

              

@app.exception_handler(StarletteHTTPException)
async def http_exception_handler(request, exc):
    return PlainTextResponse(str(exc.detail), status_code=exc.status_code)


@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request, exc):

            

Reported by Pylint.

Unused argument 'request'
Error

Line: 15 Column: 40

              

@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request, exc):
    return PlainTextResponse(str(exc), status_code=400)


@app.get("/items/{item_id}")
async def read_item(item_id: int):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from fastapi import FastAPI, HTTPException
from fastapi.exceptions import RequestValidationError
from fastapi.responses import PlainTextResponse
from starlette.exceptions import HTTPException as StarletteHTTPException

app = FastAPI()


@app.exception_handler(StarletteHTTPException)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              

@app.exception_handler(StarletteHTTPException)
async def http_exception_handler(request, exc):
    return PlainTextResponse(str(exc.detail), status_code=exc.status_code)


@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request, exc):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              

@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request, exc):
    return PlainTextResponse(str(exc), status_code=400)


@app.get("/items/{item_id}")
async def read_item(item_id: int):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

              

@app.get("/items/{item_id}")
async def read_item(item_id: int):
    if item_id == 3:
        raise HTTPException(status_code=418, detail="Nope! I don't like 3.")
    return {"item_id": item_id}

            

Reported by Pylint.

tests/test_tutorial/test_response_model/test_tutorial005.py
10 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.response_model.tutorial005 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: 123 Column: 1

              }


def test_openapi_schema():
    response = client.get("/openapi.json")
    assert response.status_code == 200, response.text
    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: 125
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

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


def test_read_item_name():
    response = client.get("/items/bar/name")

            

Reported by Bandit.

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

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

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


def test_read_item_name():
    response = client.get("/items/bar/name")
    assert response.status_code == 200, response.text

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 129 Column: 1

                  assert response.json() == openapi_schema


def test_read_item_name():
    response = client.get("/items/bar/name")
    assert response.status_code == 200, response.text
    assert response.json() == {"name": "Bar", "description": "The Bar fighters"}



            

Reported by Pylint.

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

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

              
def test_read_item_name():
    response = client.get("/items/bar/name")
    assert response.status_code == 200, response.text
    assert response.json() == {"name": "Bar", "description": "The Bar fighters"}


def test_read_item_public_data():
    response = client.get("/items/bar/public")

            

Reported by Bandit.

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

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

              def test_read_item_name():
    response = client.get("/items/bar/name")
    assert response.status_code == 200, response.text
    assert response.json() == {"name": "Bar", "description": "The Bar fighters"}


def test_read_item_public_data():
    response = client.get("/items/bar/public")
    assert response.status_code == 200, response.text

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 135 Column: 1

                  assert response.json() == {"name": "Bar", "description": "The Bar fighters"}


def test_read_item_public_data():
    response = client.get("/items/bar/public")
    assert response.status_code == 200, response.text
    assert response.json() == {
        "name": "Bar",
        "description": "The Bar fighters",

            

Reported by Pylint.

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

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

              
def test_read_item_public_data():
    response = client.get("/items/bar/public")
    assert response.status_code == 200, response.text
    assert response.json() == {
        "name": "Bar",
        "description": "The Bar fighters",
        "price": 62,
    }

            

Reported by Bandit.

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

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

              def test_read_item_public_data():
    response = client.get("/items/bar/public")
    assert response.status_code == 200, response.text
    assert response.json() == {
        "name": "Bar",
        "description": "The Bar fighters",
        "price": 62,
    }

            

Reported by Bandit.

tests/test_tutorial/test_extra_models/test_tutorial003.py
10 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.extra_models.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: 103 Column: 1

              }


def test_openapi_schema():
    response = client.get("/openapi.json")
    assert response.status_code == 200, response.text
    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: 105
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

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


def test_get_car():
    response = client.get("/items/item1")

            

Reported by Bandit.

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

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

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


def test_get_car():
    response = client.get("/items/item1")
    assert response.status_code == 200, response.text

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 109 Column: 1

                  assert response.json() == openapi_schema


def test_get_car():
    response = client.get("/items/item1")
    assert response.status_code == 200, response.text
    assert response.json() == {
        "description": "All my friends drive a low rider",
        "type": "car",

            

Reported by Pylint.

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

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

              
def test_get_car():
    response = client.get("/items/item1")
    assert response.status_code == 200, response.text
    assert response.json() == {
        "description": "All my friends drive a low rider",
        "type": "car",
    }


            

Reported by Bandit.

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

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

              def test_get_car():
    response = client.get("/items/item1")
    assert response.status_code == 200, response.text
    assert response.json() == {
        "description": "All my friends drive a low rider",
        "type": "car",
    }



            

Reported by Bandit.

Missing function or method docstring
Error

Line: 118 Column: 1

                  }


def test_get_plane():
    response = client.get("/items/item2")
    assert response.status_code == 200, response.text
    assert response.json() == {
        "description": "Music is my aeroplane, it's my aeroplane",
        "type": "plane",

            

Reported by Pylint.

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

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

              
def test_get_plane():
    response = client.get("/items/item2")
    assert response.status_code == 200, response.text
    assert response.json() == {
        "description": "Music is my aeroplane, it's my aeroplane",
        "type": "plane",
        "size": 5,
    }

            

Reported by Bandit.

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

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

              def test_get_plane():
    response = client.get("/items/item2")
    assert response.status_code == 200, response.text
    assert response.json() == {
        "description": "Music is my aeroplane, it's my aeroplane",
        "type": "plane",
        "size": 5,
    }

            

Reported by Bandit.

docs_src/extra_models/tutorial003.py
10 issues
Unable to import 'fastapi'
Error

Line: 3 Column: 1

              from typing import Union

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class BaseItem(BaseModel):

            

Reported by Pylint.

Unable to import 'pydantic'
Error

Line: 4 Column: 1

              from typing import Union

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class BaseItem(BaseModel):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Union

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class BaseItem(BaseModel):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 9 Column: 1

              app = FastAPI()


class BaseItem(BaseModel):
    description: str
    type: str


class CarItem(BaseItem):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              app = FastAPI()


class BaseItem(BaseModel):
    description: str
    type: str


class CarItem(BaseItem):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 14 Column: 1

                  type: str


class CarItem(BaseItem):
    type = "car"


class PlaneItem(BaseItem):
    type = "plane"

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

                  type: str


class CarItem(BaseItem):
    type = "car"


class PlaneItem(BaseItem):
    type = "plane"

            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

                  type = "car"


class PlaneItem(BaseItem):
    type = "plane"
    size: int


items = {

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 18 Column: 1

                  type = "car"


class PlaneItem(BaseItem):
    type = "plane"
    size: int


items = {

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 1

              

@app.get("/items/{item_id}", response_model=Union[PlaneItem, CarItem])
async def read_item(item_id: str):
    return items[item_id]

            

Reported by Pylint.

docs_src/body_nested_models/tutorial007.py
10 issues
Unable to import 'fastapi'
Error

Line: 3 Column: 1

              from typing import List, Optional, Set

from fastapi import FastAPI
from pydantic import BaseModel, HttpUrl

app = FastAPI()


class Image(BaseModel):

            

Reported by Pylint.

Unable to import 'pydantic'
Error

Line: 4 Column: 1

              from typing import List, Optional, Set

from fastapi import FastAPI
from pydantic import BaseModel, HttpUrl

app = FastAPI()


class Image(BaseModel):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import List, Optional, Set

from fastapi import FastAPI
from pydantic import BaseModel, HttpUrl

app = FastAPI()


class Image(BaseModel):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              app = FastAPI()


class Image(BaseModel):
    url: HttpUrl
    name: str


class Item(BaseModel):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 9 Column: 1

              app = FastAPI()


class Image(BaseModel):
    url: HttpUrl
    name: str


class Item(BaseModel):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 14 Column: 1

                  name: str


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

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

                  name: str


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

            

Reported by Pylint.

Missing class docstring
Error

Line: 23 Column: 1

                  images: Optional[List[Image]] = None


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


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 23 Column: 1

                  images: Optional[List[Image]] = None


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


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 1

              

@app.post("/offers/")
async def create_offer(offer: Offer):
    return offer

            

Reported by Pylint.

tests/test_tutorial/test_handling_errors/test_tutorial003.py
10 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.handling_errors.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: 74 Column: 1

              }


def test_openapi_schema():
    response = client.get("/openapi.json")
    assert response.status_code == 200, response.text
    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: 76
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

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


def test_get():
    response = client.get("/unicorns/shinny")

            

Reported by Bandit.

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

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

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


def test_get():
    response = client.get("/unicorns/shinny")
    assert response.status_code == 200, response.text

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 80 Column: 1

                  assert response.json() == openapi_schema


def test_get():
    response = client.get("/unicorns/shinny")
    assert response.status_code == 200, response.text
    assert response.json() == {"unicorn_name": "shinny"}



            

Reported by Pylint.

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

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

              
def test_get():
    response = client.get("/unicorns/shinny")
    assert response.status_code == 200, response.text
    assert response.json() == {"unicorn_name": "shinny"}


def test_get_exception():
    response = client.get("/unicorns/yolo")

            

Reported by Bandit.

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

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

              def test_get():
    response = client.get("/unicorns/shinny")
    assert response.status_code == 200, response.text
    assert response.json() == {"unicorn_name": "shinny"}


def test_get_exception():
    response = client.get("/unicorns/yolo")
    assert response.status_code == 418, response.text

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 86 Column: 1

                  assert response.json() == {"unicorn_name": "shinny"}


def test_get_exception():
    response = client.get("/unicorns/yolo")
    assert response.status_code == 418, response.text
    assert response.json() == {
        "message": "Oops! yolo did something. There goes a rainbow..."
    }

            

Reported by Pylint.

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

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

              
def test_get_exception():
    response = client.get("/unicorns/yolo")
    assert response.status_code == 418, response.text
    assert response.json() == {
        "message": "Oops! yolo did something. There goes a rainbow..."
    }

            

Reported by Bandit.

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

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

              def test_get_exception():
    response = client.get("/unicorns/yolo")
    assert response.status_code == 418, response.text
    assert response.json() == {
        "message": "Oops! yolo did something. There goes a rainbow..."
    }

            

Reported by Bandit.