The following issues were found

examples/addons/http-modify-form.py
3 issues
Unable to import 'mitmproxy'
Error

Line: 2 Column: 1

              """Modify an HTTP form submission."""
from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    if flow.request.urlencoded_form:
        # If there's already a form, one can just add items to the dict:
        flow.request.urlencoded_form["mitmproxy"] = "rocks"
    else:

            

Reported by Pylint.

Module name "http-modify-form" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              """Modify an HTTP form submission."""
from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    if flow.request.urlencoded_form:
        # If there's already a form, one can just add items to the dict:
        flow.request.urlencoded_form["mitmproxy"] = "rocks"
    else:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    if flow.request.urlencoded_form:
        # If there's already a form, one can just add items to the dict:
        flow.request.urlencoded_form["mitmproxy"] = "rocks"
    else:
        # One can also just pass new form data.

            

Reported by Pylint.

examples/addons/duplicate-modify-replay.py
3 issues
Unable to import 'mitmproxy'
Error

Line: 2 Column: 1

              """Take incoming HTTP requests and replay them with modified parameters."""
from mitmproxy import ctx


def request(flow):
    # Avoid an infinite loop by not replaying already replayed requests
    if flow.is_replay == "request":
        return
    flow = flow.copy()

            

Reported by Pylint.

Module name "duplicate-modify-replay" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              """Take incoming HTTP requests and replay them with modified parameters."""
from mitmproxy import ctx


def request(flow):
    # Avoid an infinite loop by not replaying already replayed requests
    if flow.is_replay == "request":
        return
    flow = flow.copy()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              from mitmproxy import ctx


def request(flow):
    # Avoid an infinite loop by not replaying already replayed requests
    if flow.is_replay == "request":
        return
    flow = flow.copy()
    # Only interactive tools have a view. If we have one, add a duplicate entry

            

Reported by Pylint.

test/mitmproxy/utils/test_emoji.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              from mitmproxy.utils import emoji
from mitmproxy.tools.console.common import SYMBOL_MARK


def test_emoji():
    assert emoji.emoji[":default:"] == SYMBOL_MARK

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              from mitmproxy.tools.console.common import SYMBOL_MARK


def test_emoji():
    assert emoji.emoji[":default:"] == SYMBOL_MARK

            

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_emoji():
    assert emoji.emoji[":default:"] == SYMBOL_MARK

            

Reported by Bandit.

docs/scripts/options.py
3 issues
Unable to import 'mitmproxy'
Error

Line: 3 Column: 1

              #!/usr/bin/env python3

from mitmproxy import options, optmanager
from mitmproxy.tools import dump, console, web

masters = {
    "mitmproxy": console.master.ConsoleMaster,
    "mitmdump": dump.DumpMaster,
    "mitmweb": web.master.WebMaster

            

Reported by Pylint.

Unable to import 'mitmproxy.tools'
Error

Line: 4 Column: 1

              #!/usr/bin/env python3

from mitmproxy import options, optmanager
from mitmproxy.tools import dump, console, web

masters = {
    "mitmproxy": console.master.ConsoleMaster,
    "mitmdump": dump.DumpMaster,
    "mitmweb": web.master.WebMaster

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3

from mitmproxy import options, optmanager
from mitmproxy.tools import dump, console, web

masters = {
    "mitmproxy": console.master.ConsoleMaster,
    "mitmdump": dump.DumpMaster,
    "mitmweb": web.master.WebMaster

            

Reported by Pylint.

test/mitmproxy/contentviews/__init__.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              def full_eval(instance):
    def call(data, **metadata):
        x = instance(data, **metadata)
        if x is None:
            return None
        name, generator = x
        return name, list(generator)

    return call

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 1 Column: 1

              def full_eval(instance):
    def call(data, **metadata):
        x = instance(data, **metadata)
        if x is None:
            return None
        name, generator = x
        return name, list(generator)

    return call

            

Reported by Pylint.

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

Line: 3 Column: 9

              def full_eval(instance):
    def call(data, **metadata):
        x = instance(data, **metadata)
        if x is None:
            return None
        name, generator = x
        return name, list(generator)

    return call

            

Reported by Pylint.

mitmproxy/proxy/server_hooks.py
2 issues
Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              from dataclasses import dataclass

from mitmproxy import connection
from . import commands


@dataclass
class ClientConnectedHook(commands.StartHook):
    """

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from dataclasses import dataclass

from mitmproxy import connection
from . import commands


@dataclass
class ClientConnectedHook(commands.StartHook):
    """

            

Reported by Pylint.

mitmproxy/script/__init__.py
2 issues
Unable to import '__init__.concurrent'
Error

Line: 1 Column: 1

              from .concurrent import concurrent

__all__ = [
    "concurrent",
]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from .concurrent import concurrent

__all__ = [
    "concurrent",
]

            

Reported by Pylint.

mitmproxy/tcp.py
2 issues
Class 'Flow' has no '_stateobject_attributes' member
Error

Line: 47 Column: 31

                      super().__init__("tcp", client_conn, server_conn, live)
        self.messages: List[TCPMessage] = []

    _stateobject_attributes = flow.Flow._stateobject_attributes.copy()
    _stateobject_attributes["messages"] = List[TCPMessage]

    def __repr__(self):
        return "<TCPFlow ({} messages)>".format(len(self.messages))


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import time
from typing import List

from mitmproxy import flow
from mitmproxy.coretypes import serializable


class TCPMessage(serializable.Serializable):
    """

            

Reported by Pylint.

mitmproxy/test/tutils.py
2 issues
Unable to import 'mitmproxy'
Error

Line: 1 Column: 1

              from mitmproxy import http


def treq(**kwargs) -> http.Request:
    """
    Returns:
        mitmproxy.net.http.Request
    """
    default = dict(

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from mitmproxy import http


def treq(**kwargs) -> http.Request:
    """
    Returns:
        mitmproxy.net.http.Request
    """
    default = dict(

            

Reported by Pylint.

mitmproxy/addons/__init__.py
2 issues
Missing module docstring
Error

Line: 1 Column: 1

              from mitmproxy.addons import anticache
from mitmproxy.addons import anticomp
from mitmproxy.addons import block
from mitmproxy.addons import blocklist
from mitmproxy.addons import browser
from mitmproxy.addons import clientplayback
from mitmproxy.addons import command_history
from mitmproxy.addons import comment
from mitmproxy.addons import core

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 1

              from mitmproxy.addons import upstream_auth


def default_addons():
    return [
        core.Core(),
        browser.Browser(),
        block.Block(),
        blocklist.BlockList(),

            

Reported by Pylint.