The following issues were found

test/mitmproxy/proxy/test_server_hooks.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              from mitmproxy.proxy import server_hooks


def test_noop():
    assert server_hooks

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              from mitmproxy.proxy import server_hooks


def test_noop():
    assert server_hooks

            

Reported by Pylint.

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

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

              

def test_noop():
    assert server_hooks

            

Reported by Bandit.

mitmproxy/log.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              import asyncio
from dataclasses import dataclass

from mitmproxy import hooks


class LogEntry:
    def __init__(self, msg, level):
        # it's important that we serialize to string here already so that we don't pick up changes

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              from mitmproxy import hooks


class LogEntry:
    def __init__(self, msg, level):
        # it's important that we serialize to string here already so that we don't pick up changes
        # happening after this log statement.
        self.msg = str(msg)
        self.level = level

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 88 Column: 1

              ]


def log_tier(level):
    return dict(error=0, warn=1, info=2, alert=2, debug=3).get(level)

            

Reported by Pylint.

mitmproxy/coretypes/serializable.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              import abc
import uuid
from typing import Type, TypeVar

T = TypeVar('T', bound='Serializable')


class Serializable(metaclass=abc.ABCMeta):
    """

            

Reported by Pylint.

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

Line: 5 Column: 1

              import uuid
from typing import Type, TypeVar

T = TypeVar('T', bound='Serializable')


class Serializable(metaclass=abc.ABCMeta):
    """
    Abstract Base Class that defines an API to save an object's state and restore it later on.

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 5

                      """
        raise NotImplementedError()

    def copy(self: T) -> T:
        state = self.get_state()
        if isinstance(state, dict) and "id" in state:
            state["id"] = str(uuid.uuid4())
        return self.from_state(state)

            

Reported by Pylint.

mitmproxy/contrib/wbxml/InvalidDataException.py
3 issues
Module name "InvalidDataException" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
'''
@author: David Shaw, shawd@vmware.com

Inspired by EAS Inspector for Fiddler
https://easinspectorforfiddler.codeplex.com

----- The MIT License (MIT) ----- 
Filename: InvalidDataException.py

            

Reported by Pylint.

Trailing whitespace
Error

Line: 8 Column: 34

              Inspired by EAS Inspector for Fiddler
https://easinspectorforfiddler.codeplex.com

----- The MIT License (MIT) ----- 
Filename: InvalidDataException.py
Copyright (c) 2014, David P. Shaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

            

Reported by Pylint.

Missing class docstring
Error

Line: 30 Column: 1

              OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''
class InvalidDataException(Exception):
    pass

            

Reported by Pylint.

examples/contrib/all_markers.py
3 issues
Unable to import 'mitmproxy'
Error

Line: 1 Column: 1

              from mitmproxy import ctx, command
from mitmproxy.utils import emoji


@command.command('all.markers')
def all_markers():
    'Create a new flow showing all marker values'
    for marker in emoji.emoji:
        ctx.master.commands.call('view.flows.create', 'get', f'https://example.com/{marker}')

            

Reported by Pylint.

Unable to import 'mitmproxy.utils'
Error

Line: 2 Column: 1

              from mitmproxy import ctx, command
from mitmproxy.utils import emoji


@command.command('all.markers')
def all_markers():
    'Create a new flow showing all marker values'
    for marker in emoji.emoji:
        ctx.master.commands.call('view.flows.create', 'get', f'https://example.com/{marker}')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from mitmproxy import ctx, command
from mitmproxy.utils import emoji


@command.command('all.markers')
def all_markers():
    'Create a new flow showing all marker values'
    for marker in emoji.emoji:
        ctx.master.commands.call('view.flows.create', 'get', f'https://example.com/{marker}')

            

Reported by Pylint.

examples/addons/internet-in-mirror.py
3 issues
Unable to import 'mitmproxy'
Error

Line: 6 Column: 1

              
Useful if you are living down under.
"""
from mitmproxy import http


def response(flow: http.HTTPFlow) -> None:
    if flow.response and flow.response.content:
        flow.response.content = flow.response.content.replace(

            

Reported by Pylint.

Module name "internet-in-mirror" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              """
Mirror all web pages.

Useful if you are living down under.
"""
from mitmproxy import http


def response(flow: http.HTTPFlow) -> None:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              from mitmproxy import http


def response(flow: http.HTTPFlow) -> None:
    if flow.response and flow.response.content:
        flow.response.content = flow.response.content.replace(
            b"</head>",
            b"<style>body {transform: scaleX(-1);}</style></head>"
        )

            

Reported by Pylint.

docs/scripts/api-render.py
3 issues
Unable to import 'pdoc.render_helpers'
Error

Line: 7 Column: 1

              import textwrap
from pathlib import Path

import pdoc.render_helpers

here = Path(__file__).parent

if os.environ.get("DOCS_ARCHIVE", False):
    edit_url_map = {}

            

Reported by Pylint.

Module name "api-render" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
import os
import shutil
import textwrap
from pathlib import Path

import pdoc.render_helpers

here = Path(__file__).parent

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
import os
import shutil
import textwrap
from pathlib import Path

import pdoc.render_helpers

here = Path(__file__).parent

            

Reported by Pylint.

examples/addons/http-reply-from-proxy.py
3 issues
Unable to import 'mitmproxy'
Error

Line: 2 Column: 1

              """Send a reply from the proxy without sending any data to the remote server."""
from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    if flow.request.pretty_url == "http://example.com/path":
        flow.response = http.Response.make(
            200,  # (optional) status code
            b"Hello World",  # (optional) content

            

Reported by Pylint.

Module name "http-reply-from-proxy" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              """Send a reply from the proxy without sending any data to the remote server."""
from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    if flow.request.pretty_url == "http://example.com/path":
        flow.response = http.Response.make(
            200,  # (optional) status code
            b"Hello World",  # (optional) content

            

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.pretty_url == "http://example.com/path":
        flow.response = http.Response.make(
            200,  # (optional) status code
            b"Hello World",  # (optional) content
            {"Content-Type": "text/html"}  # (optional) headers

            

Reported by Pylint.

examples/addons/http-redirect-requests.py
3 issues
Unable to import 'mitmproxy'
Error

Line: 2 Column: 1

              """Redirect HTTP requests to another server."""
from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    # pretty_host takes the "Host" header of the request into account,
    # which is useful in transparent mode where we usually only have the IP
    # otherwise.
    if flow.request.pretty_host == "example.org":

            

Reported by Pylint.

Module name "http-redirect-requests" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              """Redirect HTTP requests to another server."""
from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    # pretty_host takes the "Host" header of the request into account,
    # which is useful in transparent mode where we usually only have the IP
    # otherwise.
    if flow.request.pretty_host == "example.org":

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    # pretty_host takes the "Host" header of the request into account,
    # which is useful in transparent mode where we usually only have the IP
    # otherwise.
    if flow.request.pretty_host == "example.org":
        flow.request.host = "mitmproxy.org"

            

Reported by Pylint.

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

Line: 2 Column: 1

              """Modify HTTP query parameters."""
from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    flow.request.query["mitmproxy"] = "rocks"

            

Reported by Pylint.

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

Line: 1 Column: 1

              """Modify HTTP query parameters."""
from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    flow.request.query["mitmproxy"] = "rocks"

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    flow.request.query["mitmproxy"] = "rocks"

            

Reported by Pylint.