mirror of
https://github.com/kuhyx/testsAndMisc-archive.git
synced 2026-07-04 21:43:04 +02:00
- R0914 (too many locals): Extract helper functions in generate_jpeg.py, engine.py, lichess_api.py, main.py - R0902 (too many instance attributes): Use dataclasses in keyboard_coop - W0621 (redefined outer name): Rename parameters/variables to avoid shadowing - W0201 (attribute outside init): Initialize all attrs in __init__ - R1705 (no-else-return): Remove unnecessary else after return - C1805 (implicit booleaness): Use implicit boolean checks - R1732 (consider-using-with): Use context manager for subprocess.Popen - E0401 (import-error): Add pylint disable for optional deps (selenium, mitmproxy) - Clean up pyproject.toml: update comments, remove redundant settings Pylint score: 10.00/10
15 lines
504 B
Python
15 lines
504 B
Python
"""Mitmproxy addon to simulate connection failures."""
|
|
|
|
from mitmproxy import http # pylint: disable=import-error
|
|
|
|
|
|
def request(flow: http.HTTPFlow) -> None:
|
|
"""Intercept requests and simulate failures for specific hosts."""
|
|
# Only intercept traffic to example.com
|
|
if "example.com" in flow.request.host:
|
|
flow.response = http.Response.make(
|
|
502, # Bad Gateway status code
|
|
b"Simulated connection failure",
|
|
{"Content-Type": "text/plain"},
|
|
)
|