The following issues were found

docs_src/dependencies/tutorial010.py
6 issues
Undefined variable 'DBSession'
Error

Line: 3 Column: 19

              class MySuperContextManager:
    def __init__(self):
        self.db = DBSession()

    def __enter__(self):
        return self.db

    def __exit__(self, exc_type, exc_value, traceback):
        self.db.close()

            

Reported by Pylint.

Missing class docstring
Error

Line: 1 Column: 1

              class MySuperContextManager:
    def __init__(self):
        self.db = DBSession()

    def __enter__(self):
        return self.db

    def __exit__(self, exc_type, exc_value, traceback):
        self.db.close()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              class MySuperContextManager:
    def __init__(self):
        self.db = DBSession()

    def __enter__(self):
        return self.db

    def __exit__(self, exc_type, exc_value, traceback):
        self.db.close()

            

Reported by Pylint.

Attribute name "db" doesn't conform to snake_case naming style
Error

Line: 3 Column: 9

              class MySuperContextManager:
    def __init__(self):
        self.db = DBSession()

    def __enter__(self):
        return self.db

    def __exit__(self, exc_type, exc_value, traceback):
        self.db.close()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

                      self.db.close()


async def get_db():
    with MySuperContextManager() as db:
        yield db

            

Reported by Pylint.

Variable name "db" doesn't conform to snake_case naming style
Error

Line: 13 Column: 37

              

async def get_db():
    with MySuperContextManager() as db:
        yield db

            

Reported by Pylint.

docs_src/extra_models/tutorial004.py
6 issues
Unable to import 'fastapi'
Error

Line: 3 Column: 1

              from typing import List

from fastapi import 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 List

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import List

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 9 Column: 1

              app = FastAPI()


class Item(BaseModel):
    name: str
    description: str


items = [

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              app = FastAPI()


class Item(BaseModel):
    name: str
    description: str


items = [

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

              

@app.get("/items/", response_model=List[Item])
async def read_items():
    return items

            

Reported by Pylint.

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

Line: 3 Column: 1

              from typing import Optional, Set

from fastapi import FastAPI, status
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, Set

from fastapi import FastAPI, status
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Optional, Set

from fastapi import FastAPI, status
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
    tags: Set[str] = []

            

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
    tags: Set[str] = []

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              

@app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED)
async def create_item(item: Item):
    return item

            

Reported by Pylint.

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

Line: 1 Column: 1

              from fastapi import Depends, FastAPI

app = FastAPI()


class FixedContentQueryChecker:
    def __init__(self, fixed_content: str):
        self.fixed_content = fixed_content


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from fastapi import Depends, FastAPI

app = FastAPI()


class FixedContentQueryChecker:
    def __init__(self, fixed_content: str):
        self.fixed_content = fixed_content


            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              app = FastAPI()


class FixedContentQueryChecker:
    def __init__(self, fixed_content: str):
        self.fixed_content = fixed_content

    def __call__(self, q: str = ""):
        if q:

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 6 Column: 1

              app = FastAPI()


class FixedContentQueryChecker:
    def __init__(self, fixed_content: str):
        self.fixed_content = fixed_content

    def __call__(self, q: str = ""):
        if q:

            

Reported by Pylint.

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

Line: 10 Column: 5

                  def __init__(self, fixed_content: str):
        self.fixed_content = fixed_content

    def __call__(self, q: str = ""):
        if q:
            return self.fixed_content in q
        return False



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

              

@app.get("/query-checker/")
async def read_query_check(fixed_content_included: bool = Depends(checker)):
    return {"fixed_content_in_query": fixed_content_included}

            

Reported by Pylint.

docs_src/response_model/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, EmailStr

app = FastAPI()


class UserIn(BaseModel):

            

Reported by Pylint.

Unable to import 'pydantic'
Error

Line: 4 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel, EmailStr

app = FastAPI()


class UserIn(BaseModel):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Optional

from fastapi import FastAPI
from pydantic import BaseModel, EmailStr

app = FastAPI()


class UserIn(BaseModel):

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 9 Column: 1

              app = FastAPI()


class UserIn(BaseModel):
    username: str
    password: str
    email: EmailStr
    full_name: Optional[str] = None


            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              app = FastAPI()


class UserIn(BaseModel):
    username: str
    password: str
    email: EmailStr
    full_name: Optional[str] = None


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              
# Don't do this in production!
@app.post("/user/", response_model=UserIn)
async def create_user(user: UserIn):
    return user

            

Reported by Pylint.

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

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.

Unable to import 'pydantic'
Error

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.

Missing module docstring
Error

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.

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
    tags: List[str] = []

            

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
    tags: List[str] = []

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              

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

            

Reported by Pylint.

docs_src/custom_response/tutorial007.py
6 issues
Unable to import 'fastapi'
Error

Line: 1 Column: 1

              from fastapi import FastAPI
from fastapi.responses import StreamingResponse

app = FastAPI()


async def fake_video_streamer():
    for i in range(10):
        yield b"some fake video bytes"

            

Reported by Pylint.

Unable to import 'fastapi.responses'
Error

Line: 2 Column: 1

              from fastapi import FastAPI
from fastapi.responses import StreamingResponse

app = FastAPI()


async def fake_video_streamer():
    for i in range(10):
        yield b"some fake video bytes"

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 8 Column: 9

              

async def fake_video_streamer():
    for i in range(10):
        yield b"some fake video bytes"


@app.get("/")
async def main():

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from fastapi import FastAPI
from fastapi.responses import StreamingResponse

app = FastAPI()


async def fake_video_streamer():
    for i in range(10):
        yield b"some fake video bytes"

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              app = FastAPI()


async def fake_video_streamer():
    for i in range(10):
        yield b"some fake video bytes"


@app.get("/")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              

@app.get("/")
async def main():
    return StreamingResponse(fake_video_streamer())

            

Reported by Pylint.

tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial005.py
6 issues
Missing module docstring
Error

Line: 1 Column: 1

              from fastapi.testclient import TestClient

from docs_src.path_operation_advanced_configuration.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: 28 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: 30
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("/items/")

            

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_schema():
    response = client.get("/openapi.json")
    assert response.status_code == 200, response.text
    assert response.json() == openapi_schema


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

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 34 Column: 1

                  assert response.json() == openapi_schema


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

            

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_get():
    response = client.get("/items/")
    assert response.status_code == 200, response.text

            

Reported by Bandit.

tests/test_tutorial/test_background_tasks/test_tutorial001.py
6 issues
Missing module docstring
Error

Line: 1 Column: 1

              import os
from pathlib import Path

from fastapi.testclient import TestClient

from docs_src.background_tasks.tutorial001 import app

client = TestClient(app)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              client = TestClient(app)


def test():
    log = Path("log.txt")
    if log.is_file():
        os.remove(log)  # pragma: no cover
    response = client.post("/send-notification/foo@example.com")
    assert response.status_code == 200, response.text

            

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

                  if log.is_file():
        os.remove(log)  # pragma: no cover
    response = client.post("/send-notification/foo@example.com")
    assert response.status_code == 200, response.text
    assert response.json() == {"message": "Notification sent in the background"}
    with open("./log.txt") as f:
        assert "notification for foo@example.com: some notification" in f.read()

            

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

                      os.remove(log)  # pragma: no cover
    response = client.post("/send-notification/foo@example.com")
    assert response.status_code == 200, response.text
    assert response.json() == {"message": "Notification sent in the background"}
    with open("./log.txt") as f:
        assert "notification for foo@example.com: some notification" in f.read()

            

Reported by Bandit.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 18 Column: 31

                  response = client.post("/send-notification/foo@example.com")
    assert response.status_code == 200, response.text
    assert response.json() == {"message": "Notification sent in the background"}
    with open("./log.txt") as f:
        assert "notification for foo@example.com: some notification" in f.read()

            

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

                  assert response.status_code == 200, response.text
    assert response.json() == {"message": "Notification sent in the background"}
    with open("./log.txt") as f:
        assert "notification for foo@example.com: some notification" in f.read()

            

Reported by Bandit.

docs_src/settings/app03/config.py
6 issues
Unable to import 'pydantic'
Error

Line: 1 Column: 1

              from pydantic import BaseSettings


class Settings(BaseSettings):
    app_name: str = "Awesome API"
    admin_email: str
    items_per_user: int = 50

    class Config:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from pydantic import BaseSettings


class Settings(BaseSettings):
    app_name: str = "Awesome API"
    admin_email: str
    items_per_user: int = 50

    class Config:

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 4 Column: 1

              from pydantic import BaseSettings


class Settings(BaseSettings):
    app_name: str = "Awesome API"
    admin_email: str
    items_per_user: int = 50

    class Config:

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              from pydantic import BaseSettings


class Settings(BaseSettings):
    app_name: str = "Awesome API"
    admin_email: str
    items_per_user: int = 50

    class Config:

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 5

                  admin_email: str
    items_per_user: int = 50

    class Config:
        env_file = ".env"

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 9 Column: 5

                  admin_email: str
    items_per_user: int = 50

    class Config:
        env_file = ".env"

            

Reported by Pylint.