The following issues were found

src/flask/templating.py
17 issues
Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              from jinja2 import Template
from jinja2 import TemplateNotFound

from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .signals import before_render_template
from .signals import template_rendered

if t.TYPE_CHECKING:

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              from jinja2 import TemplateNotFound

from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .signals import before_render_template
from .signals import template_rendered

if t.TYPE_CHECKING:
    from .app import Flask

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              
from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .signals import before_render_template
from .signals import template_rendered

if t.TYPE_CHECKING:
    from .app import Flask
    from .scaffold import Scaffold

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

              from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .signals import before_render_template
from .signals import template_rendered

if t.TYPE_CHECKING:
    from .app import Flask
    from .scaffold import Scaffold


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 14 Column: 5

              from .signals import template_rendered

if t.TYPE_CHECKING:
    from .app import Flask
    from .scaffold import Scaffold


def _default_template_ctx_processor() -> t.Dict[str, t.Any]:
    """Default template context processor.  Injects `request`,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 15 Column: 5

              
if t.TYPE_CHECKING:
    from .app import Flask
    from .scaffold import Scaffold


def _default_template_ctx_processor() -> t.Dict[str, t.Any]:
    """Default template context processor.  Injects `request`,
    `session` and `g`.

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 79 Column: 9

                              rv = None
            attempts.append((loader, srcobj, rv))

        from .debughelpers import explain_template_loading_attempts

        explain_template_loading_attempts(self.app, template, attempts)

        if trv is not None:
            return trv

            

Reported by Pylint.

Unused Flask imported from app
Error

Line: 14 Column: 5

              from .signals import template_rendered

if t.TYPE_CHECKING:
    from .app import Flask
    from .scaffold import Scaffold


def _default_template_ctx_processor() -> t.Dict[str, t.Any]:
    """Default template context processor.  Injects `request`,

            

Reported by Pylint.

Unused Scaffold imported from scaffold
Error

Line: 15 Column: 5

              
if t.TYPE_CHECKING:
    from .app import Flask
    from .scaffold import Scaffold


def _default_template_ctx_processor() -> t.Dict[str, t.Any]:
    """Default template context processor.  Injects `request`,
    `session` and `g`.

            

Reported by Pylint.

Unused argument 'template'
Error

Line: 98 Column: 15

                      raise TemplateNotFound(template)

    def _iter_loaders(
        self, template: str
    ) -> t.Generator[t.Tuple["Scaffold", BaseLoader], None, None]:
        loader = self.app.jinja_loader
        if loader is not None:
            yield self.app, loader


            

Reported by Pylint.

src/flask/wrappers.py
16 issues
Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              from werkzeug.wrappers import Request as RequestBase
from werkzeug.wrappers import Response as ResponseBase

from . import json
from .globals import current_app
from .helpers import _split_blueprint_path

if t.TYPE_CHECKING:
    import typing_extensions as te

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              from werkzeug.wrappers import Response as ResponseBase

from . import json
from .globals import current_app
from .helpers import _split_blueprint_path

if t.TYPE_CHECKING:
    import typing_extensions as te
    from werkzeug.routing import Rule

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              
from . import json
from .globals import current_app
from .helpers import _split_blueprint_path

if t.TYPE_CHECKING:
    import typing_extensions as te
    from werkzeug.routing import Rule


            

Reported by Pylint.

Unable to import 'typing_extensions'
Error

Line: 12 Column: 5

              from .helpers import _split_blueprint_path

if t.TYPE_CHECKING:
    import typing_extensions as te
    from werkzeug.routing import Rule


class Request(RequestBase):
    """The request object used by default in Flask.  Remembers the

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 123 Column: 13

                          and self.mimetype != "multipart/form-data"
            and not self.files
        ):
            from .debughelpers import attach_enctype_error_multidict

            attach_enctype_error_multidict(self)

    def on_json_loading_failed(self, e: Exception) -> "te.NoReturn":
        if current_app and current_app.debug:

            

Reported by Pylint.

Unused typing_extensions imported as te
Error

Line: 12 Column: 5

              from .helpers import _split_blueprint_path

if t.TYPE_CHECKING:
    import typing_extensions as te
    from werkzeug.routing import Rule


class Request(RequestBase):
    """The request object used by default in Flask.  Remembers the

            

Reported by Pylint.

Unused Rule imported from werkzeug.routing
Error

Line: 13 Column: 5

              
if t.TYPE_CHECKING:
    import typing_extensions as te
    from werkzeug.routing import Rule


class Request(RequestBase):
    """The request object used by default in Flask.  Remembers the
    matched endpoint and view arguments.

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import typing as t

from werkzeug.exceptions import BadRequest
from werkzeug.wrappers import Request as RequestBase
from werkzeug.wrappers import Response as ResponseBase

from . import json
from .globals import current_app
from .helpers import _split_blueprint_path

            

Reported by Pylint.

Imports from package werkzeug are not grouped
Error

Line: 13 Column: 5

              
if t.TYPE_CHECKING:
    import typing_extensions as te
    from werkzeug.routing import Rule


class Request(RequestBase):
    """The request object used by default in Flask.  Remembers the
    matched endpoint and view arguments.

            

Reported by Pylint.

Too many ancestors (9/7)
Error

Line: 16 Column: 1

                  from werkzeug.routing import Rule


class Request(RequestBase):
    """The request object used by default in Flask.  Remembers the
    matched endpoint and view arguments.

    It is what ends up as :class:`~flask.request`.  If you want to replace
    the request object used you can subclass this and set

            

Reported by Pylint.

src/flask/testing.py
16 issues
Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              from werkzeug.urls import url_parse
from werkzeug.wrappers import Request as BaseRequest

from . import _request_ctx_stack
from .cli import ScriptInfo
from .json import dumps as json_dumps
from .sessions import SessionMixin

if t.TYPE_CHECKING:

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 13 Column: 1

              from werkzeug.wrappers import Request as BaseRequest

from . import _request_ctx_stack
from .cli import ScriptInfo
from .json import dumps as json_dumps
from .sessions import SessionMixin

if t.TYPE_CHECKING:
    from .app import Flask

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 14 Column: 1

              
from . import _request_ctx_stack
from .cli import ScriptInfo
from .json import dumps as json_dumps
from .sessions import SessionMixin

if t.TYPE_CHECKING:
    from .app import Flask
    from .wrappers import Response

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 15 Column: 1

              from . import _request_ctx_stack
from .cli import ScriptInfo
from .json import dumps as json_dumps
from .sessions import SessionMixin

if t.TYPE_CHECKING:
    from .app import Flask
    from .wrappers import Response


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 18 Column: 5

              from .sessions import SessionMixin

if t.TYPE_CHECKING:
    from .app import Flask
    from .wrappers import Response


class EnvironBuilder(werkzeug.test.EnvironBuilder):
    """An :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 19 Column: 5

              
if t.TYPE_CHECKING:
    from .app import Flask
    from .wrappers import Response


class EnvironBuilder(werkzeug.test.EnvironBuilder):
    """An :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the
    application.

            

Reported by Pylint.

Unused Flask imported from app
Error

Line: 18 Column: 5

              from .sessions import SessionMixin

if t.TYPE_CHECKING:
    from .app import Flask
    from .wrappers import Response


class EnvironBuilder(werkzeug.test.EnvironBuilder):
    """An :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the

            

Reported by Pylint.

Unused Response imported from wrappers
Error

Line: 19 Column: 5

              
if t.TYPE_CHECKING:
    from .app import Flask
    from .wrappers import Response


class EnvironBuilder(werkzeug.test.EnvironBuilder):
    """An :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the
    application.

            

Reported by Pylint.

Keyword argument before variable positional arguments list in the definition of __init__ function
Error

Line: 44 Column: 5

                      :class:`~werkzeug.test.EnvironBuilder`.
    """

    def __init__(
        self,
        app: "Flask",
        path: str = "/",
        base_url: t.Optional[str] = None,
        subdomain: t.Optional[str] = None,

            

Reported by Pylint.

Parameters differ from overridden 'open' method
Error

Line: 174 Column: 5

                          headers = resp.get_wsgi_headers(c.request.environ)
            self.cookie_jar.extract_wsgi(c.request.environ, headers)

    def open(  # type: ignore
        self,
        *args: t.Any,
        as_tuple: bool = False,
        buffered: bool = False,
        follow_redirects: bool = False,

            

Reported by Pylint.

examples/tutorial/tests/conftest.py
15 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import os
import tempfile

import pytest

from flaskr import create_app
from flaskr.db import get_db
from flaskr.db import init_db


            

Reported by Pylint.

Unable to import 'flaskr'
Error

Line: 6 Column: 1

              
import pytest

from flaskr import create_app
from flaskr.db import get_db
from flaskr.db import init_db

# read in SQL for populating test data
with open(os.path.join(os.path.dirname(__file__), "data.sql"), "rb") as f:

            

Reported by Pylint.

Unable to import 'flaskr.db'
Error

Line: 7 Column: 1

              import pytest

from flaskr import create_app
from flaskr.db import get_db
from flaskr.db import init_db

# read in SQL for populating test data
with open(os.path.join(os.path.dirname(__file__), "data.sql"), "rb") as f:
    _data_sql = f.read().decode("utf8")

            

Reported by Pylint.

Unable to import 'flaskr.db'
Error

Line: 8 Column: 1

              
from flaskr import create_app
from flaskr.db import get_db
from flaskr.db import init_db

# read in SQL for populating test data
with open(os.path.join(os.path.dirname(__file__), "data.sql"), "rb") as f:
    _data_sql = f.read().decode("utf8")


            

Reported by Pylint.

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

Line: 21 Column: 5

                  # create a temporary file to isolate the database for each test
    db_fd, db_path = tempfile.mkstemp()
    # create the app with common test config
    app = create_app({"TESTING": True, "DATABASE": db_path})

    # create the database and load test data
    with app.app_context():
        init_db()
        get_db().executescript(_data_sql)

            

Reported by Pylint.

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

Line: 36 Column: 12

              

@pytest.fixture
def client(app):
    """A test client for the app."""
    return app.test_client()


@pytest.fixture

            

Reported by Pylint.

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

Line: 42 Column: 12

              

@pytest.fixture
def runner(app):
    """A test runner for the app's Click commands."""
    return app.test_cli_runner()


class AuthActions:

            

Reported by Pylint.

Redefining name 'client' from outer scope (line 36)
Error

Line: 48 Column: 24

              

class AuthActions:
    def __init__(self, client):
        self._client = client

    def login(self, username="test", password="test"):
        return self._client.post(
            "/auth/login", data={"username": username, "password": password}

            

Reported by Pylint.

Redefining name 'client' from outer scope (line 36)
Error

Line: 61 Column: 10

              

@pytest.fixture
def auth(client):
    return AuthActions(client)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import tempfile

import pytest

from flaskr import create_app
from flaskr.db import get_db
from flaskr.db import init_db


            

Reported by Pylint.

src/flask/config.py
15 issues
Attempted relative import beyond top-level package
Error

Line: 223 Column: 9

                      .. versionadded:: 0.11
        """
        import warnings
        from . import json

        warnings.warn(
            "'from_json' is deprecated and will be removed in Flask"
            " 2.1. Use 'from_file(path, json.load)' instead.",
            DeprecationWarning,

            

Reported by Pylint.

Use of exec detected.
Security

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

                      d.__file__ = filename
        try:
            with open(filename, mode="rb") as config_file:
                exec(compile(config_file.read(), filename, "exec"), d.__dict__)
        except OSError as e:
            if silent and e.errno in (errno.ENOENT, errno.EISDIR, errno.ENOTDIR):
                return False
            e.strerror = f"Unable to load configuration file ({e.strerror})"
            raise

            

Reported by Bandit.

Use of exec
Error

Line: 120 Column: 17

                      d.__file__ = filename
        try:
            with open(filename, mode="rb") as config_file:
                exec(compile(config_file.read(), filename, "exec"), d.__dict__)
        except OSError as e:
            if silent and e.errno in (errno.ENOENT, errno.EISDIR, errno.ENOTDIR):
                return False
            e.strerror = f"Unable to load configuration file ({e.strerror})"
            raise

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import errno
import os
import types
import typing as t

from werkzeug.utils import import_string


class ConfigAttribute:

            

Reported by Pylint.

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

Line: 19 Column: 9

                  def __get__(self, obj: t.Any, owner: t.Any = None) -> t.Any:
        if obj is None:
            return self
        rv = obj.config[self.__name__]
        if self.get_converter is not None:
            rv = self.get_converter(rv)
        return rv

    def __set__(self, obj: t.Any, value: t.Any) -> None:

            

Reported by Pylint.

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

Line: 21 Column: 13

                          return self
        rv = obj.config[self.__name__]
        if self.get_converter is not None:
            rv = self.get_converter(rv)
        return rv

    def __set__(self, obj: t.Any, value: t.Any) -> None:
        obj.config[self.__name__] = value


            

Reported by Pylint.

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

Line: 88 Column: 9

                                     files.
        :return: ``True`` if the file was loaded successfully.
        """
        rv = os.environ.get(variable_name)
        if not rv:
            if silent:
                return False
            raise RuntimeError(
                f"The environment variable {variable_name!r} is not set"

            

Reported by Pylint.

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

Line: 116 Column: 9

                         `silent` parameter.
        """
        filename = os.path.join(self.root_path, filename)
        d = types.ModuleType("config")
        d.__file__ = filename
        try:
            with open(filename, mode="rb") as config_file:
                exec(compile(config_file.read(), filename, "exec"), d.__dict__)
        except OSError as e:

            

Reported by Pylint.

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

Line: 121 Column: 9

                      try:
            with open(filename, mode="rb") as config_file:
                exec(compile(config_file.read(), filename, "exec"), d.__dict__)
        except OSError as e:
            if silent and e.errno in (errno.ENOENT, errno.EISDIR, errno.ENOTDIR):
                return False
            e.strerror = f"Unable to load configuration file ({e.strerror})"
            raise
        self.from_object(d)

            

Reported by Pylint.

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

Line: 196 Column: 36

                      filename = os.path.join(self.root_path, filename)

        try:
            with open(filename) as f:
                obj = load(f)
        except OSError as e:
            if silent and e.errno in (errno.ENOENT, errno.EISDIR):
                return False


            

Reported by Pylint.

examples/tutorial/tests/test_db.py
13 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              import sqlite3

import pytest

from flaskr.db import get_db


def test_get_close_db(app):
    with app.app_context():

            

Reported by Pylint.

Unable to import 'flaskr.db'
Error

Line: 5 Column: 1

              
import pytest

from flaskr.db import get_db


def test_get_close_db(app):
    with app.app_context():
        db = get_db()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import sqlite3

import pytest

from flaskr.db import get_db


def test_get_close_db(app):
    with app.app_context():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              from flaskr.db import get_db


def test_get_close_db(app):
    with app.app_context():
        db = get_db()
        assert db is get_db()

    with pytest.raises(sqlite3.ProgrammingError) as e:

            

Reported by Pylint.

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

Line: 10 Column: 9

              
def test_get_close_db(app):
    with app.app_context():
        db = get_db()
        assert db is get_db()

    with pytest.raises(sqlite3.ProgrammingError) as e:
        db.execute("SELECT 1")


            

Reported by Pylint.

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_get_close_db(app):
    with app.app_context():
        db = get_db()
        assert db is get_db()

    with pytest.raises(sqlite3.ProgrammingError) as e:
        db.execute("SELECT 1")

    assert "closed" in str(e.value)

            

Reported by Bandit.

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

Line: 13 Column: 53

                      db = get_db()
        assert db is get_db()

    with pytest.raises(sqlite3.ProgrammingError) as e:
        db.execute("SELECT 1")

    assert "closed" in str(e.value)



            

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

                  with pytest.raises(sqlite3.ProgrammingError) as e:
        db.execute("SELECT 1")

    assert "closed" in str(e.value)


def test_init_db_command(runner, monkeypatch):
    class Recorder:
        called = False

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 19 Column: 1

                  assert "closed" in str(e.value)


def test_init_db_command(runner, monkeypatch):
    class Recorder:
        called = False

    def fake_init_db():
        Recorder.called = True

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 20 Column: 5

              

def test_init_db_command(runner, monkeypatch):
    class Recorder:
        called = False

    def fake_init_db():
        Recorder.called = True


            

Reported by Pylint.

src/flask/json/__init__.py
13 issues
Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              from jinja2.utils import htmlsafe_json_dumps as _jinja_htmlsafe_dumps
from werkzeug.http import http_date

from ..globals import current_app
from ..globals import request

if t.TYPE_CHECKING:
    from ..app import Flask
    from ..wrappers import Response

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 13 Column: 1

              from werkzeug.http import http_date

from ..globals import current_app
from ..globals import request

if t.TYPE_CHECKING:
    from ..app import Flask
    from ..wrappers import Response


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 16 Column: 5

              from ..globals import request

if t.TYPE_CHECKING:
    from ..app import Flask
    from ..wrappers import Response

try:
    import dataclasses
except ImportError:

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 17 Column: 5

              
if t.TYPE_CHECKING:
    from ..app import Flask
    from ..wrappers import Response

try:
    import dataclasses
except ImportError:
    # Python < 3.7

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import decimal
import io
import json as _json
import typing as t
import uuid
import warnings
from datetime import date

from jinja2.utils import htmlsafe_json_dumps as _jinja_htmlsafe_dumps

            

Reported by Pylint.

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

Line: 80 Column: 9

              
    if app:
        cls = app.json_encoder
        bp = app.blueprints.get(request.blueprint) if request else None  # type: ignore
        if bp is not None and bp.json_encoder is not None:
            cls = bp.json_encoder

        kwargs.setdefault("cls", cls)
        kwargs.setdefault("ensure_ascii", app.config["JSON_AS_ASCII"])

            

Reported by Pylint.

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

Line: 101 Column: 9

              
    if app:
        cls = app.json_decoder
        bp = app.blueprints.get(request.blueprint) if request else None  # type: ignore
        if bp is not None and bp.json_decoder is not None:
            cls = bp.json_decoder

        kwargs.setdefault("cls", cls)
    else:

            

Reported by Pylint.

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

Line: 133 Column: 5

                  """
    _dump_arg_defaults(kwargs, app=app)
    encoding = kwargs.pop("encoding", None)
    rv = _json.dumps(obj, **kwargs)

    if encoding is not None:
        warnings.warn(
            "'encoding' is deprecated and will be removed in Flask 2.1.",
            DeprecationWarning,

            

Reported by Pylint.

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

Line: 148 Column: 1

                  return rv


def dump(
    obj: t.Any, fp: t.IO[str], app: t.Optional["Flask"] = None, **kwargs: t.Any
) -> None:
    """Serialize an object to JSON written to a file object.

    Takes the same arguments as the built-in :func:`json.dump`, with

            

Reported by Pylint.

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

Line: 187 Column: 1

                  _json.dump(obj, fp, **kwargs)


def loads(s: str, app: t.Optional["Flask"] = None, **kwargs: t.Any) -> t.Any:
    """Deserialize an object from a string of JSON.

    Takes the same arguments as the built-in :func:`json.loads`, with
    some defaults from application configuration.


            

Reported by Pylint.

src/flask/debughelpers.py
12 issues
Attempted relative import beyond top-level package
Error

Line: 5 Column: 1

              import typing as t
from warnings import warn

from .app import Flask
from .blueprints import Blueprint
from .globals import _request_ctx_stack


class UnexpectedUnicodeError(AssertionError, UnicodeError):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              from warnings import warn

from .app import Flask
from .blueprints import Blueprint
from .globals import _request_ctx_stack


class UnexpectedUnicodeError(AssertionError, UnicodeError):
    """Raised in places where we want some better error reporting for

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              
from .app import Flask
from .blueprints import Blueprint
from .globals import _request_ctx_stack


class UnexpectedUnicodeError(AssertionError, UnicodeError):
    """Raised in places where we want some better error reporting for
    unexpected unicode or binary data.

            

Reported by Pylint.

__init__ method from base class 'KeyError' is not called
Error

Line: 21 Column: 5

                  provide a better error message than just a generic KeyError/BadRequest.
    """

    def __init__(self, request, key):
        form_matches = request.form.getlist(key)
        buf = [
            f"You tried to access the file {key!r} in the request.files"
            " dictionary but it does not exist. The mimetype for the"
            f" request is {request.mimetype!r} instead of"

            

Reported by Pylint.

__init__ method from base class 'AssertionError' is not called
Error

Line: 21 Column: 5

                  provide a better error message than just a generic KeyError/BadRequest.
    """

    def __init__(self, request, key):
        form_matches = request.form.getlist(key)
        buf = [
            f"You tried to access the file {key!r} in the request.files"
            " dictionary but it does not exist. The mimetype for the"
            f" request is {request.mimetype!r} instead of"

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 89 Column: 17

                          except KeyError:
                if key not in request.form:
                    raise
                raise DebugFilesKeyError(request, key)

    newcls.__name__ = oldcls.__name__
    newcls.__module__ = oldcls.__module__
    request.files.__class__ = newcls


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import typing as t
from warnings import warn

from .app import Flask
from .blueprints import Blueprint
from .globals import _request_ctx_stack



            

Reported by Pylint.

Class name "newcls" doesn't conform to PascalCase naming style
Error

Line: 82 Column: 5

                  """
    oldcls = request.files.__class__

    class newcls(oldcls):
        def __getitem__(self, key):
            try:
                return oldcls.__getitem__(self, key)
            except KeyError:
                if key not in request.form:

            

Reported by Pylint.

Missing class docstring
Error

Line: 82 Column: 5

                  """
    oldcls = request.files.__class__

    class newcls(oldcls):
        def __getitem__(self, key):
            try:
                return oldcls.__getitem__(self, key)
            except KeyError:
                if key not in request.form:

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 82 Column: 5

                  """
    oldcls = request.files.__class__

    class newcls(oldcls):
        def __getitem__(self, key):
            try:
                return oldcls.__getitem__(self, key)
            except KeyError:
                if key not in request.form:

            

Reported by Pylint.

tests/test_converters.py
12 issues
Unused variable 'index'
Error

Line: 20 Column: 5

                  app.url_map.converters["list"] = ListConverter

    @app.route("/<list:args>")
    def index(args):
        return "|".join(args)

    assert client.get("/1,2,3").data == b"1|2|3"

    with app.test_request_context():

            

Reported by Pylint.

Unused variable 'index'
Error

Line: 39 Column: 5

                  app.url_map.converters["ctx"] = ContextConverter

    @app.get("/<ctx:name>")
    def index(name):
        return name

    assert client.get("/admin").data == b"admin"

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from werkzeug.routing import BaseConverter

from flask import request
from flask import session
from flask import url_for


def test_custom_converters(app, client):
    class ListConverter(BaseConverter):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              from flask import url_for


def test_custom_converters(app, client):
    class ListConverter(BaseConverter):
        def to_python(self, value):
            return value.split(",")

        def to_url(self, value):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 5

              

def test_custom_converters(app, client):
    class ListConverter(BaseConverter):
        def to_python(self, value):
            return value.split(",")

        def to_url(self, value):
            base_to_url = super().to_url

            

Reported by Pylint.

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 index(args):
        return "|".join(args)

    assert client.get("/1,2,3").data == b"1|2|3"

    with app.test_request_context():
        assert url_for("index", args=[4, 5, 6]) == "/4,5,6"



            

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

                  assert client.get("/1,2,3").data == b"1|2|3"

    with app.test_request_context():
        assert url_for("index", args=[4, 5, 6]) == "/4,5,6"


def test_context_available(app, client):
    class ContextConverter(BaseConverter):
        def to_python(self, value):

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 29 Column: 1

                      assert url_for("index", args=[4, 5, 6]) == "/4,5,6"


def test_context_available(app, client):
    class ContextConverter(BaseConverter):
        def to_python(self, value):
            assert request is not None
            assert session is not None
            return value

            

Reported by Pylint.

Missing class docstring
Error

Line: 30 Column: 5

              

def test_context_available(app, client):
    class ContextConverter(BaseConverter):
        def to_python(self, value):
            assert request is not None
            assert session is not None
            return value


            

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_context_available(app, client):
    class ContextConverter(BaseConverter):
        def to_python(self, value):
            assert request is not None
            assert session is not None
            return value

    app.url_map.converters["ctx"] = ContextConverter


            

Reported by Bandit.

tests/test_regression.py
12 issues
Unused variable 'handle_foo'
Error

Line: 9 Column: 5

                      whatever = 42

    @app.errorhandler(Foo)
    def handle_foo(e):
        return str(e.whatever)

    @app.route("/")
    def index():
        raise flask.abort(flask.redirect(flask.url_for("test")))

            

Reported by Pylint.

Unused variable 'index'
Error

Line: 13 Column: 5

                      return str(e.whatever)

    @app.route("/")
    def index():
        raise flask.abort(flask.redirect(flask.url_for("test")))

    @app.route("/test")
    def test():
        raise Foo()

            

Reported by Pylint.

Unused variable 'test'
Error

Line: 17 Column: 5

                      raise flask.abort(flask.redirect(flask.url_for("test")))

    @app.route("/test")
    def test():
        raise Foo()

    with app.test_client() as c:
        rv = c.get("/")
        assert rv.headers["Location"] == "http://localhost/test"

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import flask


def test_aborting(app):
    class Foo(Exception):
        whatever = 42

    @app.errorhandler(Foo)
    def handle_foo(e):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              import flask


def test_aborting(app):
    class Foo(Exception):
        whatever = 42

    @app.errorhandler(Foo)
    def handle_foo(e):

            

Reported by Pylint.

Missing class docstring
Error

Line: 5 Column: 5

              

def test_aborting(app):
    class Foo(Exception):
        whatever = 42

    @app.errorhandler(Foo)
    def handle_foo(e):
        return str(e.whatever)

            

Reported by Pylint.

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

Line: 9 Column: 5

                      whatever = 42

    @app.errorhandler(Foo)
    def handle_foo(e):
        return str(e.whatever)

    @app.route("/")
    def index():
        raise flask.abort(flask.redirect(flask.url_for("test")))

            

Reported by Pylint.

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

Line: 20 Column: 31

                  def test():
        raise Foo()

    with app.test_client() as c:
        rv = c.get("/")
        assert rv.headers["Location"] == "http://localhost/test"
        rv = c.get("/test")
        assert rv.data == b"42"

            

Reported by Pylint.

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

Line: 21 Column: 9

                      raise Foo()

    with app.test_client() as c:
        rv = c.get("/")
        assert rv.headers["Location"] == "http://localhost/test"
        rv = c.get("/test")
        assert rv.data == b"42"

            

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

              
    with app.test_client() as c:
        rv = c.get("/")
        assert rv.headers["Location"] == "http://localhost/test"
        rv = c.get("/test")
        assert rv.data == b"42"

            

Reported by Bandit.