The following issues were found

tests/conftest.py
39 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              import sys
import textwrap

import pytest
from _pytest import monkeypatch

import flask
from flask import Flask as _Flask


            

Reported by Pylint.

Unable to import '_pytest'
Error

Line: 7 Column: 1

              import textwrap

import pytest
from _pytest import monkeypatch

import flask
from flask import Flask as _Flask



            

Reported by Pylint.

Redefining name 'monkeypatch' from outer scope (line 7)
Error

Line: 39 Column: 23

              

@pytest.fixture(autouse=True)
def _reset_os_environ(monkeypatch, _standard_os_environ):
    """Reset ``os.environ`` to the standard environ after each test,
    in case a test changed something without cleaning up.
    """
    monkeypatch._setitem.extend(_standard_os_environ)


            

Reported by Pylint.

Access to a protected member _setitem of a client class
Error

Line: 43 Column: 5

                  """Reset ``os.environ`` to the standard environ after each test,
    in case a test changed something without cleaning up.
    """
    monkeypatch._setitem.extend(_standard_os_environ)


class Flask(_Flask):
    testing = True
    secret_key = "test key"

            

Reported by Pylint.

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

Line: 53 Column: 5

              
@pytest.fixture
def app():
    app = Flask("flask_test", root_path=os.path.dirname(__file__))
    return app


@pytest.fixture
def app_ctx(app):

            

Reported by Pylint.

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

Line: 58 Column: 13

              

@pytest.fixture
def app_ctx(app):
    with app.app_context() as ctx:
        yield ctx


@pytest.fixture

            

Reported by Pylint.

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

Line: 64 Column: 13

              

@pytest.fixture
def req_ctx(app):
    with app.test_request_context() as ctx:
        yield ctx


@pytest.fixture

            

Reported by Pylint.

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

Line: 70 Column: 12

              

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


@pytest.fixture
def test_apps(monkeypatch):

            

Reported by Pylint.

Redefining name 'monkeypatch' from outer scope (line 7)
Error

Line: 75 Column: 15

              

@pytest.fixture
def test_apps(monkeypatch):
    monkeypatch.syspath_prepend(os.path.join(os.path.dirname(__file__), "test_apps"))
    original_modules = set(sys.modules.keys())

    yield


            

Reported by Pylint.

Access to a protected member _request_ctx_stack of a client class
Error

Line: 94 Column: 11

                  # make sure we're not leaking a request context since we are
    # testing flask internally in debug mode in a few cases
    leaks = []
    while flask._request_ctx_stack.top is not None:
        leaks.append(flask._request_ctx_stack.pop())
    assert leaks == []


@pytest.fixture(params=(True, False))

            

Reported by Pylint.

tests/test_async.py
35 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import asyncio
import sys

import pytest

from flask import Blueprint
from flask import Flask
from flask import request
from flask.views import MethodView

            

Reported by Pylint.

Instance of 'Flask' has no 'async_to_sync' member
Error

Line: 163 Column: 9

              def test_async_runtime_error():
    app = Flask(__name__)
    with pytest.raises(RuntimeError):
        app.async_to_sync(None)

            

Reported by Pylint.

Method 'dispatch_request' was expected to be 'non-async', found it instead as 'async'
Error

Line: 26 Column: 5

              class AsyncView(View):
    methods = ["GET", "POST"]

    async def dispatch_request(self):
        await asyncio.sleep(0)
        return request.method


class AsyncMethodView(MethodView):

            

Reported by Pylint.

Unused variable 'index'
Error

Line: 47 Column: 5

              
    @app.route("/", methods=["GET", "POST"])
    @app.route("/home", methods=["GET", "POST"])
    async def index():
        await asyncio.sleep(0)
        return request.method

    @app.errorhandler(AppError)
    async def handle(_):

            

Reported by Pylint.

Unused variable 'handle'
Error

Line: 52 Column: 5

                      return request.method

    @app.errorhandler(AppError)
    async def handle(_):
        return "", 412

    @app.route("/error")
    async def error():
        raise AppError()

            

Reported by Pylint.

Unused variable 'error'
Error

Line: 56 Column: 5

                      return "", 412

    @app.route("/error")
    async def error():
        raise AppError()

    blueprint = Blueprint("bp", __name__)

    @blueprint.route("/", methods=["GET", "POST"])

            

Reported by Pylint.

Unused variable 'bp_index'
Error

Line: 62 Column: 5

                  blueprint = Blueprint("bp", __name__)

    @blueprint.route("/", methods=["GET", "POST"])
    async def bp_index():
        await asyncio.sleep(0)
        return request.method

    @blueprint.errorhandler(BlueprintError)
    async def bp_handle(_):

            

Reported by Pylint.

Unused variable 'bp_handle'
Error

Line: 67 Column: 5

                      return request.method

    @blueprint.errorhandler(BlueprintError)
    async def bp_handle(_):
        return "", 412

    @blueprint.route("/error")
    async def bp_error():
        raise BlueprintError()

            

Reported by Pylint.

Unused variable 'bp_error'
Error

Line: 71 Column: 5

                      return "", 412

    @blueprint.route("/error")
    async def bp_error():
        raise BlueprintError()

    app.register_blueprint(blueprint, url_prefix="/bp")

    app.add_url_rule("/view", view_func=AsyncView.as_view("view"))

            

Reported by Pylint.

Unused variable 'index'
Error

Line: 111 Column: 5

                  app = Flask(__name__)

    @app.route("/")
    def index():
        return ""

    @app.before_first_request
    async def before_first():
        nonlocal app_first_called

            

Reported by Pylint.

src/flask/sessions.py
34 issues
Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

              from itsdangerous import URLSafeTimedSerializer
from werkzeug.datastructures import CallbackDict

from .helpers import is_ip
from .json.tag import TaggedJSONSerializer

if t.TYPE_CHECKING:
    import typing_extensions as te
    from .app import Flask

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              from werkzeug.datastructures import CallbackDict

from .helpers import is_ip
from .json.tag import TaggedJSONSerializer

if t.TYPE_CHECKING:
    import typing_extensions as te
    from .app import Flask
    from .wrappers import Request, Response

            

Reported by Pylint.

Unable to import 'typing_extensions'
Error

Line: 15 Column: 5

              from .json.tag import TaggedJSONSerializer

if t.TYPE_CHECKING:
    import typing_extensions as te
    from .app import Flask
    from .wrappers import Request, Response


class SessionMixin(MutableMapping):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 16 Column: 5

              
if t.TYPE_CHECKING:
    import typing_extensions as te
    from .app import Flask
    from .wrappers import Request, Response


class SessionMixin(MutableMapping):
    """Expands a basic dictionary with session attributes."""

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 17 Column: 5

              if t.TYPE_CHECKING:
    import typing_extensions as te
    from .app import Flask
    from .wrappers import Request, Response


class SessionMixin(MutableMapping):
    """Expands a basic dictionary with session attributes."""


            

Reported by Pylint.

Unused typing_extensions imported as te
Error

Line: 15 Column: 5

              from .json.tag import TaggedJSONSerializer

if t.TYPE_CHECKING:
    import typing_extensions as te
    from .app import Flask
    from .wrappers import Request, Response


class SessionMixin(MutableMapping):

            

Reported by Pylint.

Unused Flask imported from app
Error

Line: 16 Column: 5

              
if t.TYPE_CHECKING:
    import typing_extensions as te
    from .app import Flask
    from .wrappers import Request, Response


class SessionMixin(MutableMapping):
    """Expands a basic dictionary with session attributes."""

            

Reported by Pylint.

Unused Response imported from wrappers
Error

Line: 17 Column: 5

              if t.TYPE_CHECKING:
    import typing_extensions as te
    from .app import Flask
    from .wrappers import Request, Response


class SessionMixin(MutableMapping):
    """Expands a basic dictionary with session attributes."""


            

Reported by Pylint.

Unused Request imported from wrappers
Error

Line: 17 Column: 5

              if t.TYPE_CHECKING:
    import typing_extensions as te
    from .app import Flask
    from .wrappers import Request, Response


class SessionMixin(MutableMapping):
    """Expands a basic dictionary with session attributes."""


            

Reported by Pylint.

Method '__iter__' is abstract in class 'Iterable' but is not overridden
Error

Line: 20 Column: 1

                  from .wrappers import Request, Response


class SessionMixin(MutableMapping):
    """Expands a basic dictionary with session attributes."""

    @property
    def permanent(self) -> bool:
        """This reflects the ``'_permanent'`` key in the dict."""

            

Reported by Pylint.

src/flask/ctx.py
33 issues
Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              
from werkzeug.exceptions import HTTPException

from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .signals import appcontext_popped
from .signals import appcontext_pushed
from .typing import AfterRequestCallable


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              from werkzeug.exceptions import HTTPException

from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .signals import appcontext_popped
from .signals import appcontext_pushed
from .typing import AfterRequestCallable

if t.TYPE_CHECKING:

            

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 appcontext_popped
from .signals import appcontext_pushed
from .typing import AfterRequestCallable

if t.TYPE_CHECKING:
    from .app import Flask

            

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 appcontext_popped
from .signals import appcontext_pushed
from .typing import AfterRequestCallable

if t.TYPE_CHECKING:
    from .app import Flask
    from .sessions import SessionMixin

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              from .globals import _request_ctx_stack
from .signals import appcontext_popped
from .signals import appcontext_pushed
from .typing import AfterRequestCallable

if t.TYPE_CHECKING:
    from .app import Flask
    from .sessions import SessionMixin
    from .wrappers import Request

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 15 Column: 5

              from .typing import AfterRequestCallable

if t.TYPE_CHECKING:
    from .app import Flask
    from .sessions import SessionMixin
    from .wrappers import Request


# a singleton sentinel value for parameter defaults

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 16 Column: 5

              
if t.TYPE_CHECKING:
    from .app import Flask
    from .sessions import SessionMixin
    from .wrappers import Request


# a singleton sentinel value for parameter defaults
_sentinel = object()

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 17 Column: 5

              if t.TYPE_CHECKING:
    from .app import Flask
    from .sessions import SessionMixin
    from .wrappers import Request


# a singleton sentinel value for parameter defaults
_sentinel = object()


            

Reported by Pylint.

request_close is not callable
Error

Line: 435 Column: 21

              
                request_close = getattr(self.request, "close", None)
                if request_close is not None:
                    request_close()
                clear_request = True
        finally:
            rv = _request_ctx_stack.pop()

            # get rid of circular dependencies at the end of the request

            

Reported by Pylint.

Unused Flask imported from app
Error

Line: 15 Column: 5

              from .typing import AfterRequestCallable

if t.TYPE_CHECKING:
    from .app import Flask
    from .sessions import SessionMixin
    from .wrappers import Request


# a singleton sentinel value for parameter defaults

            

Reported by Pylint.

examples/tutorial/tests/test_blog.py
33 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from flaskr.db import get_db


def test_index(client, auth):
    response = client.get("/")
    assert b"Log In" in response.data
    assert b"Register" in response.data

            

Reported by Pylint.

Unable to import 'flaskr.db'
Error

Line: 3 Column: 1

              import pytest

from flaskr.db import get_db


def test_index(client, auth):
    response = client.get("/")
    assert b"Log In" in response.data
    assert b"Register" in response.data

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from flaskr.db import get_db


def test_index(client, auth):
    response = client.get("/")
    assert b"Log In" in response.data
    assert b"Register" in response.data

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              from flaskr.db import get_db


def test_index(client, auth):
    response = client.get("/")
    assert b"Log In" in response.data
    assert b"Register" in response.data

    auth.login()

            

Reported by Pylint.

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

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

              
def test_index(client, auth):
    response = client.get("/")
    assert b"Log In" in response.data
    assert b"Register" in response.data

    auth.login()
    response = client.get("/")
    assert b"test title" in response.data

            

Reported by Bandit.

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

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

              def test_index(client, auth):
    response = client.get("/")
    assert b"Log In" in response.data
    assert b"Register" in response.data

    auth.login()
    response = client.get("/")
    assert b"test title" in response.data
    assert b"by test on 2018-01-01" in response.data

            

Reported by Bandit.

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

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

              
    auth.login()
    response = client.get("/")
    assert b"test title" in response.data
    assert b"by test on 2018-01-01" in response.data
    assert b"test\nbody" in response.data
    assert b'href="/1/update"' in response.data



            

Reported by Bandit.

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

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

                  auth.login()
    response = client.get("/")
    assert b"test title" in response.data
    assert b"by test on 2018-01-01" in response.data
    assert b"test\nbody" in response.data
    assert b'href="/1/update"' in response.data


@pytest.mark.parametrize("path", ("/create", "/1/update", "/1/delete"))

            

Reported by Bandit.

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

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

                  response = client.get("/")
    assert b"test title" in response.data
    assert b"by test on 2018-01-01" in response.data
    assert b"test\nbody" in response.data
    assert b'href="/1/update"' in response.data


@pytest.mark.parametrize("path", ("/create", "/1/update", "/1/delete"))
def test_login_required(client, path):

            

Reported by Bandit.

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

                  assert b"test title" in response.data
    assert b"by test on 2018-01-01" in response.data
    assert b"test\nbody" in response.data
    assert b'href="/1/update"' in response.data


@pytest.mark.parametrize("path", ("/create", "/1/update", "/1/delete"))
def test_login_required(client, path):
    response = client.post(path)

            

Reported by Bandit.

tests/test_json_tag.py
33 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              from datetime import timezone
from uuid import uuid4

import pytest

from flask import Markup
from flask.json.tag import JSONTag
from flask.json.tag import TaggedJSONSerializer


            

Reported by Pylint.

Method 'to_json' is abstract in class 'JSONTag' but is not overridden
Error

Line: 33 Column: 5

              

def test_duplicate_tag():
    class TagDict(JSONTag):
        key = " d"

    s = TaggedJSONSerializer()
    pytest.raises(KeyError, s.register, TagDict)
    s.register(TagDict, force=True, index=0)

            

Reported by Pylint.

Method 'check' is abstract in class 'JSONTag' but is not overridden
Error

Line: 33 Column: 5

              

def test_duplicate_tag():
    class TagDict(JSONTag):
        key = " d"

    s = TaggedJSONSerializer()
    pytest.raises(KeyError, s.register, TagDict)
    s.register(TagDict, force=True, index=0)

            

Reported by Pylint.

Method 'to_python' is abstract in class 'JSONTag' but is not overridden
Error

Line: 33 Column: 5

              

def test_duplicate_tag():
    class TagDict(JSONTag):
        key = " d"

    s = TaggedJSONSerializer()
    pytest.raises(KeyError, s.register, TagDict)
    s.register(TagDict, force=True, index=0)

            

Reported by Pylint.

Method 'check' is abstract in class 'JSONTag' but is not overridden
Error

Line: 74 Column: 5

              

def test_tag_order():
    class Tag1(JSONTag):
        key = " 1"

    class Tag2(JSONTag):
        key = " 2"


            

Reported by Pylint.

Method 'to_json' is abstract in class 'JSONTag' but is not overridden
Error

Line: 74 Column: 5

              

def test_tag_order():
    class Tag1(JSONTag):
        key = " 1"

    class Tag2(JSONTag):
        key = " 2"


            

Reported by Pylint.

Method 'to_python' is abstract in class 'JSONTag' but is not overridden
Error

Line: 74 Column: 5

              

def test_tag_order():
    class Tag1(JSONTag):
        key = " 1"

    class Tag2(JSONTag):
        key = " 2"


            

Reported by Pylint.

Method 'check' is abstract in class 'JSONTag' but is not overridden
Error

Line: 77 Column: 5

                  class Tag1(JSONTag):
        key = " 1"

    class Tag2(JSONTag):
        key = " 2"

    s = TaggedJSONSerializer()

    s.register(Tag1, index=-1)

            

Reported by Pylint.

Method 'to_python' is abstract in class 'JSONTag' but is not overridden
Error

Line: 77 Column: 5

                  class Tag1(JSONTag):
        key = " 1"

    class Tag2(JSONTag):
        key = " 2"

    s = TaggedJSONSerializer()

    s.register(Tag1, index=-1)

            

Reported by Pylint.

Method 'to_json' is abstract in class 'JSONTag' but is not overridden
Error

Line: 77 Column: 5

                  class Tag1(JSONTag):
        key = " 1"

    class Tag2(JSONTag):
        key = " 2"

    s = TaggedJSONSerializer()

    s.register(Tag1, index=-1)

            

Reported by Pylint.

tests/test_logging.py
32 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import sys
from io import StringIO

import pytest

from flask.logging import default_handler
from flask.logging import has_level_handler
from flask.logging import wsgi_errors_stream


            

Reported by Pylint.

Unused variable 'index'
Error

Line: 56 Column: 5

              
def test_wsgi_errors_stream(app, client):
    @app.route("/")
    def index():
        app.logger.error("test")
        return ""

    stream = StringIO()
    client.get("/", errors_stream=stream)

            

Reported by Pylint.

Access to a protected member _get_current_object of a client class
Error

Line: 64 Column: 12

                  client.get("/", errors_stream=stream)
    assert "ERROR in test_logging: test" in stream.getvalue()

    assert wsgi_errors_stream._get_current_object() is sys.stderr

    with app.test_request_context(errors_stream=stream):
        assert wsgi_errors_stream._get_current_object() is stream



            

Reported by Pylint.

Access to a protected member _get_current_object of a client class
Error

Line: 67 Column: 16

                  assert wsgi_errors_stream._get_current_object() is sys.stderr

    with app.test_request_context(errors_stream=stream):
        assert wsgi_errors_stream._get_current_object() is stream


def test_has_level_handler():
    logger = logging.getLogger("flask.app")
    assert not has_level_handler(logger)

            

Reported by Pylint.

Unused variable 'index'
Error

Line: 88 Column: 5

              
def test_log_view_exception(app, client):
    @app.route("/")
    def index():
        raise Exception("test")

    app.testing = False
    stream = StringIO()
    rv = client.get("/", errors_stream=stream)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import logging
import sys
from io import StringIO

import pytest

from flask.logging import default_handler
from flask.logging import has_level_handler
from flask.logging import wsgi_errors_stream

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              

@pytest.fixture(autouse=True)
def reset_logging(pytestconfig):
    root_handlers = logging.root.handlers[:]
    logging.root.handlers = []
    root_level = logging.root.level

    logger = logging.getLogger("flask_test")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 36 Column: 1

                      pytestconfig.pluginmanager.register(logging_plugin, "logging-plugin")


def test_logger(app):
    assert app.logger.name == "flask_test"
    assert app.logger.level == logging.NOTSET
    assert app.logger.handlers == [default_handler]



            

Reported by Pylint.

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

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

              

def test_logger(app):
    assert app.logger.name == "flask_test"
    assert app.logger.level == logging.NOTSET
    assert app.logger.handlers == [default_handler]


def test_logger_debug(app):

            

Reported by Bandit.

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

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

              
def test_logger(app):
    assert app.logger.name == "flask_test"
    assert app.logger.level == logging.NOTSET
    assert app.logger.handlers == [default_handler]


def test_logger_debug(app):
    app.debug = True

            

Reported by Bandit.

docs/conf.py
26 issues
Unable to import 'packaging.version'
Error

Line: 1 Column: 1

              import packaging.version
from pallets_sphinx_themes import get_version
from pallets_sphinx_themes import ProjectLink

# Project --------------------------------------------------------------

project = "Flask"
copyright = "2010 Pallets"
author = "Pallets"

            

Reported by Pylint.

Unable to import 'pallets_sphinx_themes'
Error

Line: 2 Column: 1

              import packaging.version
from pallets_sphinx_themes import get_version
from pallets_sphinx_themes import ProjectLink

# Project --------------------------------------------------------------

project = "Flask"
copyright = "2010 Pallets"
author = "Pallets"

            

Reported by Pylint.

Unable to import 'pallets_sphinx_themes'
Error

Line: 3 Column: 1

              import packaging.version
from pallets_sphinx_themes import get_version
from pallets_sphinx_themes import ProjectLink

# Project --------------------------------------------------------------

project = "Flask"
copyright = "2010 Pallets"
author = "Pallets"

            

Reported by Pylint.

Unable to import 'docutils.nodes'
Error

Line: 88 Column: 5

                  if words is None:
        words = url

    from docutils.nodes import reference
    from docutils.parsers.rst.roles import set_classes

    options = options or {}
    set_classes(options)
    node = reference(rawtext, words, refuri=url, **options)

            

Reported by Pylint.

Unable to import 'docutils.parsers.rst.roles'
Error

Line: 89 Column: 5

                      words = url

    from docutils.nodes import reference
    from docutils.parsers.rst.roles import set_classes

    options = options or {}
    set_classes(options)
    node = reference(rawtext, words, refuri=url, **options)
    return [node], []

            

Reported by Pylint.

Redefining built-in 'copyright'
Error

Line: 8 Column: 1

              # Project --------------------------------------------------------------

project = "Flask"
copyright = "2010 Pallets"
author = "Pallets"
release, version = get_version("Flask")

# General --------------------------------------------------------------


            

Reported by Pylint.

Unused argument 'name'
Error

Line: 69 Column: 17

              # Local Extensions -----------------------------------------------------


def github_link(name, rawtext, text, lineno, inliner, options=None, content=None):
    app = inliner.document.settings.env.app
    release = app.config.release
    base_url = "https://github.com/pallets/flask/tree/"

    if text.endswith(">"):

            

Reported by Pylint.

Unused argument 'content'
Error

Line: 69 Column: 69

              # Local Extensions -----------------------------------------------------


def github_link(name, rawtext, text, lineno, inliner, options=None, content=None):
    app = inliner.document.settings.env.app
    release = app.config.release
    base_url = "https://github.com/pallets/flask/tree/"

    if text.endswith(">"):

            

Reported by Pylint.

Unused argument 'lineno'
Error

Line: 69 Column: 38

              # Local Extensions -----------------------------------------------------


def github_link(name, rawtext, text, lineno, inliner, options=None, content=None):
    app = inliner.document.settings.env.app
    release = app.config.release
    base_url = "https://github.com/pallets/flask/tree/"

    if text.endswith(">"):

            

Reported by Pylint.

Redefining name 'release' from outer scope (line 10)
Error

Line: 71 Column: 5

              
def github_link(name, rawtext, text, lineno, inliner, options=None, content=None):
    app = inliner.document.settings.env.app
    release = app.config.release
    base_url = "https://github.com/pallets/flask/tree/"

    if text.endswith(">"):
        words, text = text[:-1].rsplit("<", 1)
        words = words.strip()

            

Reported by Pylint.

src/flask/helpers.py
21 issues
Attempted relative import beyond top-level package
Error

Line: 18 Column: 1

              from werkzeug.routing import BuildError
from werkzeug.urls import url_quote

from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .globals import current_app
from .globals import request
from .globals import session
from .signals import message_flashed

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 19 Column: 1

              from werkzeug.urls import url_quote

from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .globals import current_app
from .globals import request
from .globals import session
from .signals import message_flashed


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 20 Column: 1

              
from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .globals import current_app
from .globals import request
from .globals import session
from .signals import message_flashed

if t.TYPE_CHECKING:

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 21 Column: 1

              from .globals import _app_ctx_stack
from .globals import _request_ctx_stack
from .globals import current_app
from .globals import request
from .globals import session
from .signals import message_flashed

if t.TYPE_CHECKING:
    from .wrappers import Response

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 22 Column: 1

              from .globals import _request_ctx_stack
from .globals import current_app
from .globals import request
from .globals import session
from .signals import message_flashed

if t.TYPE_CHECKING:
    from .wrappers import Response


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 23 Column: 1

              from .globals import current_app
from .globals import request
from .globals import session
from .signals import message_flashed

if t.TYPE_CHECKING:
    from .wrappers import Response



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 26 Column: 5

              from .signals import message_flashed

if t.TYPE_CHECKING:
    from .wrappers import Response


def get_env() -> str:
    """Get the environment the app is running in, indicated by the
    :envvar:`FLASK_ENV` environment variable. The default is

            

Reported by Pylint.

Module 'werkzeug.utils' has no 'send_file' member
Error

Line: 612 Column: 12

              
    .. versionadded:: 0.2
    """
    return werkzeug.utils.send_file(
        **_prepare_send_file_kwargs(
            path_or_file=path_or_file,
            environ=request.environ,
            mimetype=mimetype,
            as_attachment=as_attachment,

            

Reported by Pylint.

Module 'werkzeug.utils' has no 'safe_join' member
Error

Line: 645 Column: 12

                      DeprecationWarning,
        stacklevel=2,
    )
    path = werkzeug.utils.safe_join(directory, *pathnames)

    if path is None:
        raise NotFound()

    return path

            

Reported by Pylint.

Module 'werkzeug.utils' has no 'send_from_directory' member
Error

Line: 700 Column: 12

                      )
        path = filename

    return werkzeug.utils.send_from_directory(  # type: ignore
        directory, path, **_prepare_send_file_kwargs(**kwargs)
    )


def get_root_path(import_name: str) -> str:

            

Reported by Pylint.

examples/tutorial/tests/test_auth.py
19 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest
from flask import g
from flask import session

from flaskr.db import get_db


def test_register(client, app):
    # test that viewing the page renders without template errors

            

Reported by Pylint.

Unable to import 'flaskr.db'
Error

Line: 5 Column: 1

              from flask import g
from flask import session

from flaskr.db import get_db


def test_register(client, app):
    # test that viewing the page renders without template errors
    assert client.get("/auth/register").status_code == 200

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest
from flask import g
from flask import session

from flaskr.db import get_db


def test_register(client, app):
    # test that viewing the page renders without template errors

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              from flaskr.db import get_db


def test_register(client, app):
    # test that viewing the page renders without template errors
    assert client.get("/auth/register").status_code == 200

    # test that successful registration redirects to the login page
    response = client.post("/auth/register", data={"username": "a", "password": "a"})

            

Reported by Pylint.

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

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

              
def test_register(client, app):
    # test that viewing the page renders without template errors
    assert client.get("/auth/register").status_code == 200

    # test that successful registration redirects to the login page
    response = client.post("/auth/register", data={"username": "a", "password": "a"})
    assert "http://localhost/auth/login" == response.headers["Location"]


            

Reported by Bandit.

Comparison should be response.headers['Location'] == 'http://localhost/auth/login'
Error

Line: 14 Column: 12

              
    # test that successful registration redirects to the login page
    response = client.post("/auth/register", data={"username": "a", "password": "a"})
    assert "http://localhost/auth/login" == response.headers["Location"]

    # test that the user was inserted into the database
    with app.app_context():
        assert (
            get_db().execute("SELECT * FROM user WHERE username = 'a'").fetchone()

            

Reported by Pylint.

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

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

              
    # test that successful registration redirects to the login page
    response = client.post("/auth/register", data={"username": "a", "password": "a"})
    assert "http://localhost/auth/login" == response.headers["Location"]

    # test that the user was inserted into the database
    with app.app_context():
        assert (
            get_db().execute("SELECT * FROM user WHERE username = 'a'").fetchone()

            

Reported by Bandit.

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

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

              
    # test that the user was inserted into the database
    with app.app_context():
        assert (
            get_db().execute("SELECT * FROM user WHERE username = 'a'").fetchone()
            is not None
        )



            

Reported by Bandit.

Missing function or method docstring
Error

Line: 30 Column: 1

                      ("", "", b"Username is required."),
        ("a", "", b"Password is required."),
        ("test", "test", b"already registered"),
    ),
)
def test_register_validate_input(client, username, password, message):
    response = client.post(
        "/auth/register", data={"username": username, "password": password}
    )

            

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

                  response = client.post(
        "/auth/register", data={"username": username, "password": password}
    )
    assert message in response.data


def test_login(client, auth):
    # test that viewing the page renders without template errors
    assert client.get("/auth/login").status_code == 200

            

Reported by Bandit.