The following issues were found

examples/javascript/tests/conftest.py
6 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from js_example import app


@pytest.fixture(name="app")
def fixture_app():
    app.testing = True
    yield app

            

Reported by Pylint.

Unable to import 'js_example'
Error

Line: 3 Column: 1

              import pytest

from js_example import app


@pytest.fixture(name="app")
def fixture_app():
    app.testing = True
    yield app

            

Reported by Pylint.

Redefining name 'app' from outer scope (line 3)
Error

Line: 14 Column: 12

              

@pytest.fixture
def client(app):
    return app.test_client()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from js_example import app


@pytest.fixture(name="app")
def fixture_app():
    app.testing = True
    yield app

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              

@pytest.fixture(name="app")
def fixture_app():
    app.testing = True
    yield app
    app.testing = False



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

              

@pytest.fixture
def client(app):
    return app.test_client()

            

Reported by Pylint.

examples/javascript/js_example/views.py
6 issues
Missing module docstring
Error

Line: 1 Column: 1

              from flask import jsonify
from flask import render_template
from flask import request

from js_example import app


@app.route("/", defaults={"js": "plain"})
@app.route("/<any(plain, jquery, fetch):js>")

            

Reported by Pylint.

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

Line: 10 Column: 1

              
@app.route("/", defaults={"js": "plain"})
@app.route("/<any(plain, jquery, fetch):js>")
def index(js):
    return render_template(f"{js}.html", js=js)


@app.route("/add", methods=["POST"])
def add():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              
@app.route("/", defaults={"js": "plain"})
@app.route("/<any(plain, jquery, fetch):js>")
def index(js):
    return render_template(f"{js}.html", js=js)


@app.route("/add", methods=["POST"])
def add():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              

@app.route("/add", methods=["POST"])
def add():
    a = request.form.get("a", 0, type=float)
    b = request.form.get("b", 0, type=float)
    return jsonify(result=a + b)

            

Reported by Pylint.

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

Line: 16 Column: 5

              
@app.route("/add", methods=["POST"])
def add():
    a = request.form.get("a", 0, type=float)
    b = request.form.get("b", 0, type=float)
    return jsonify(result=a + b)

            

Reported by Pylint.

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

Line: 17 Column: 5

              @app.route("/add", methods=["POST"])
def add():
    a = request.form.get("a", 0, type=float)
    b = request.form.get("b", 0, type=float)
    return jsonify(result=a + b)

            

Reported by Pylint.

examples/tutorial/tests/test_factory.py
6 issues
Unable to import 'flaskr'
Error

Line: 1 Column: 1

              from flaskr import create_app


def test_config():
    """Test create_app without passing test config."""
    assert not create_app().testing
    assert create_app({"TESTING": True}).testing



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from flaskr import create_app


def test_config():
    """Test create_app without passing test config."""
    assert not create_app().testing
    assert create_app({"TESTING": True}).testing



            

Reported by Pylint.

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

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

              
def test_config():
    """Test create_app without passing test config."""
    assert not create_app().testing
    assert create_app({"TESTING": True}).testing


def test_hello(client):
    response = client.get("/hello")

            

Reported by Bandit.

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

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

              def test_config():
    """Test create_app without passing test config."""
    assert not create_app().testing
    assert create_app({"TESTING": True}).testing


def test_hello(client):
    response = client.get("/hello")
    assert response.data == b"Hello, World!"

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 10 Column: 1

                  assert create_app({"TESTING": True}).testing


def test_hello(client):
    response = client.get("/hello")
    assert response.data == b"Hello, World!"

            

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_hello(client):
    response = client.get("/hello")
    assert response.data == b"Hello, World!"

            

Reported by Bandit.

src/flask/views.py
5 issues
Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              import typing as t

from .globals import current_app
from .globals import request
from .typing import ResponseReturnValue


http_method_funcs = frozenset(
    ["get", "post", "head", "options", "delete", "put", "trace", "patch"]

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              import typing as t

from .globals import current_app
from .globals import request
from .typing import ResponseReturnValue


http_method_funcs = frozenset(
    ["get", "post", "head", "options", "delete", "put", "trace", "patch"]

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 5 Column: 1

              
from .globals import current_app
from .globals import request
from .typing import ResponseReturnValue


http_method_funcs = frozenset(
    ["get", "post", "head", "options", "delete", "put", "trace", "patch"]
)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import typing as t

from .globals import current_app
from .globals import request
from .typing import ResponseReturnValue


http_method_funcs = frozenset(
    ["get", "post", "head", "options", "delete", "put", "trace", "patch"]

            

Reported by Pylint.

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

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

                      if meth is None and request.method == "HEAD":
            meth = getattr(self, "get", None)

        assert meth is not None, f"Unimplemented method {request.method!r}"
        return current_app.ensure_sync(meth)(*args, **kwargs)

            

Reported by Bandit.

examples/tutorial/flaskr/__init__.py
5 issues
Unused variable 'hello'
Error

Line: 30 Column: 5

                      pass

    @app.route("/hello")
    def hello():
        return "Hello, World!"

    # register the database commands
    from flaskr import db


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os

from flask import Flask


def create_app(test_config=None):
    """Create and configure an instance of the Flask application."""
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(

            

Reported by Pylint.

Possible hardcoded password: 'dev'
Security

Line: 9
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b106_hardcoded_password_funcarg.html

              def create_app(test_config=None):
    """Create and configure an instance of the Flask application."""
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(
        # a default secret that should be overridden by instance config
        SECRET_KEY="dev",
        # store the database in the instance folder
        DATABASE=os.path.join(app.instance_path, "flaskr.sqlite"),
    )

            

Reported by Bandit.

Import outside toplevel (flaskr.db)
Error

Line: 34 Column: 5

                      return "Hello, World!"

    # register the database commands
    from flaskr import db

    db.init_app(app)

    # apply the blueprints to the app
    from flaskr import auth, blog

            

Reported by Pylint.

Import outside toplevel (flaskr.auth, flaskr.blog)
Error

Line: 39 Column: 5

                  db.init_app(app)

    # apply the blueprints to the app
    from flaskr import auth, blog

    app.register_blueprint(auth.bp)
    app.register_blueprint(blog.bp)

    # make url_for('index') == url_for('blog.index')

            

Reported by Pylint.

examples/tutorial/flaskr/auth.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              import functools

from flask import Blueprint
from flask import flash
from flask import g
from flask import redirect
from flask import render_template
from flask import request
from flask import session

            

Reported by Pylint.

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

Line: 56 Column: 9

                  if request.method == "POST":
        username = request.form["username"]
        password = request.form["password"]
        db = get_db()
        error = None

        if not username:
            error = "Username is required."
        elif not password:

            

Reported by Pylint.

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

Line: 90 Column: 9

                  if request.method == "POST":
        username = request.form["username"]
        password = request.form["password"]
        db = get_db()
        error = None
        user = db.execute(
            "SELECT * FROM user WHERE username = ?", (username,)
        ).fetchone()


            

Reported by Pylint.

tests/test_apps/blueprintapp/apps/frontend/__init__.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              from flask import Blueprint
from flask import render_template

frontend = Blueprint("frontend", __name__, template_folder="templates")


@frontend.route("/")
def index():
    return render_template("frontend/index.html")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              

@frontend.route("/")
def index():
    return render_template("frontend/index.html")


@frontend.route("/missing")
def missing_template():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              

@frontend.route("/missing")
def missing_template():
    return render_template("missing_template.html")

            

Reported by Pylint.

examples/tutorial/flaskr/schema.sql
3 issues
Syntax error at or near "user"
Syntax error

Line: 4 Column: 22

              -- Initialize the database.
-- Drop any existing data and create empty tables.

DROP TABLE IF EXISTS user;
DROP TABLE IF EXISTS post;

CREATE TABLE user (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  username TEXT UNIQUE NOT NULL,

            

Reported by SQLint.

Syntax error at or near "user"
Syntax error

Line: 7 Column: 14

              DROP TABLE IF EXISTS user;
DROP TABLE IF EXISTS post;

CREATE TABLE user (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  username TEXT UNIQUE NOT NULL,
  password TEXT NOT NULL
);


            

Reported by SQLint.

Syntax error at or near "autoincrement"
Syntax error

Line: 14 Column: 26

              );

CREATE TABLE post (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  author_id INTEGER NOT NULL,
  created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  title TEXT NOT NULL,
  body TEXT NOT NULL,
  FOREIGN KEY (author_id) REFERENCES user (id)

            

Reported by SQLint.

tests/test_apps/blueprintapp/apps/admin/__init__.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              from flask import Blueprint
from flask import render_template

admin = Blueprint(
    "admin",
    __name__,
    url_prefix="/admin",
    template_folder="templates",
    static_folder="static",

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

              

@admin.route("/")
def index():
    return render_template("admin/index.html")


@admin.route("/index2")
def index2():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 1

              

@admin.route("/index2")
def index2():
    return render_template("./admin/index.html")

            

Reported by Pylint.

tests/test_apps/blueprintapp/__init__.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              from flask import Flask

app = Flask(__name__)
app.config["DEBUG"] = True
from blueprintapp.apps.admin import admin
from blueprintapp.apps.frontend import frontend

app.register_blueprint(admin)
app.register_blueprint(frontend)

            

Reported by Pylint.

Import "from blueprintapp.apps.admin import admin" should be placed at the top of the module
Error

Line: 5 Column: 1

              
app = Flask(__name__)
app.config["DEBUG"] = True
from blueprintapp.apps.admin import admin
from blueprintapp.apps.frontend import frontend

app.register_blueprint(admin)
app.register_blueprint(frontend)

            

Reported by Pylint.

Import "from blueprintapp.apps.frontend import frontend" should be placed at the top of the module
Error

Line: 6 Column: 1

              app = Flask(__name__)
app.config["DEBUG"] = True
from blueprintapp.apps.admin import admin
from blueprintapp.apps.frontend import frontend

app.register_blueprint(admin)
app.register_blueprint(frontend)

            

Reported by Pylint.