drop support for Python 3.9

This commit is contained in:
Maximilian Hils 2023-02-27 08:21:41 +01:00 committed by Maximilian Hils
parent 5259d1e31a
commit 46bfb35488
9 changed files with 19 additions and 33 deletions

View File

@ -15,30 +15,31 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: install-pinned/pyupgrade@423622e7c2088eeba495a591385ec22074284f90 - uses: install-pinned/pyupgrade@28e8d2633f6f1a03d5b4709682ce155a66324e6a
- name: Run pyupgrade - name: Run pyupgrade
run: | run: |
shopt -s globstar shopt -s globstar
export GLOBIGNORE='mitmproxy/contrib/**' export GLOBIGNORE='mitmproxy/contrib/**'
pyupgrade --exit-zero-even-if-changed --keep-runtime-typing --py39-plus **/*.py pyupgrade --exit-zero-even-if-changed --keep-runtime-typing --py310-plus **/*.py
- uses: install-pinned/reorder_python_imports@946c8bbd8fe048a3bee76063c90c938d5a59a9aa - uses: install-pinned/reorder_python_imports@2cc264e0f6bc33907796602661e5b26d8199314d
- name: Run reorder-python-imports - name: Run reorder-python-imports
run: | run: |
shopt -s globstar shopt -s globstar
export GLOBIGNORE='mitmproxy/contrib/**' export GLOBIGNORE='mitmproxy/contrib/**'
reorder-python-imports --exit-zero-even-if-changed --py39-plus **/*.py reorder-python-imports --exit-zero-even-if-changed --py310-plus **/*.py
- uses: install-pinned/yesqa@4af1e53e86a56db346a03ece9e89c19bfd0e5d0e
- uses: install-pinned/yesqa@4896f663e9c294fddfbf5f4e4fc4f9b1a4556658
- name: Run yesqa - name: Run yesqa
run: | run: |
shopt -s globstar shopt -s globstar
export GLOBIGNORE='mitmproxy/contrib/**' export GLOBIGNORE='mitmproxy/contrib/**'
yesqa **/*.py || true yesqa **/*.py || true
- uses: install-pinned/autoflake@19ecc14a8688d57cca9dc6cfd705f16f200ff097
- run: autoflake --in-place --remove-all-unused-imports --exclude contrib -r .
- uses: install-pinned/black@13c8a20eb904ba800c87f0b34ccfd932ac2ff81d - uses: install-pinned/autoflake@dfa39c5f136f5b885c175734a719dc6ad1f11fc7
- run: autoflake --in-place --remove-all-unused-imports --exclude mitmproxy/contrib -r .
- uses: install-pinned/black@3375665f712256be11c3212db472c3dafc217fa1
- run: black --extend-exclude mitmproxy/contrib . - run: black --extend-exclude mitmproxy/contrib .
- uses: mhils/add-pr-ref-in-changelog@main - uses: mhils/add-pr-ref-in-changelog@main

View File

@ -49,8 +49,6 @@ jobs:
py: "3.11" py: "3.11"
- os: ubuntu-latest - os: ubuntu-latest
py: "3.10" py: "3.10"
- os: ubuntu-latest
py: "3.9"
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- run: printenv - run: printenv

View File

@ -2,6 +2,7 @@
## Unreleased: mitmproxy next ## Unreleased: mitmproxy next
* mitmproxy now requires Python 3.10 or above.
* Fix a bug where the direction indicator in the message stream view would be in the wrong direction. * Fix a bug where the direction indicator in the message stream view would be in the wrong direction.
([#5921](https://github.com/mitmproxy/mitmproxy/issues/5921), @konradh) ([#5921](https://github.com/mitmproxy/mitmproxy/issues/5921), @konradh)
* Fix a bug where peername would be None in tls_passthrough script, which would make it not working. * Fix a bug where peername would be None in tls_passthrough script, which would make it not working.

View File

@ -14,8 +14,7 @@ forward, please consider contributing in the following areas:
## Development Setup ## Development Setup
To get started hacking on mitmproxy, please install a recent version of Python (we require at least Python 3.9). To get started hacking on mitmproxy, please install the latest version of Python and do the following:
Then, do the following:
##### Linux / macOS ##### Linux / macOS

View File

@ -2,6 +2,7 @@
import contextlib import contextlib
import inspect import inspect
import textwrap import textwrap
import typing
from pathlib import Path from pathlib import Path
from mitmproxy import addonmanager from mitmproxy import addonmanager
@ -33,15 +34,9 @@ def category(name: str, desc: str, hooks: list[type[hooks.Hook]]) -> None:
for params in all_params: for params in all_params:
for param in params: for param in params:
try: try:
mod = inspect.getmodule(param.annotation).__name__ imports.add(inspect.getmodule(param.annotation).__name__)
if mod == "typing": for t in typing.get_args(param.annotation):
# this is ugly, but can be removed once we are on Python 3.9+ only imports.add(inspect.getmodule(t).__name__)
imports.add(
inspect.getmodule(param.annotation.__args__[0]).__name__
)
types.add(param.annotation._name)
else:
imports.add(mod)
except AttributeError: except AttributeError:
raise ValueError(f"Missing type annotation: {params}") raise ValueError(f"Missing type annotation: {params}")
imports.discard("builtins") imports.discard("builtins")

View File

@ -66,7 +66,7 @@ While there are plenty of options around[^1], we recommend the installation usin
packages. Most of them (pip, virtualenv, pipenv, etc.) should just work, but we don't have the capacity to packages. Most of them (pip, virtualenv, pipenv, etc.) should just work, but we don't have the capacity to
provide support for it. provide support for it.
1. Install a recent version of Python (we require at least 3.9). 1. Install a recent version of Python (we require at least 3.10).
2. Install [pipx](https://pipxproject.github.io/pipx/). 2. Install [pipx](https://pipxproject.github.io/pipx/).
3. `pipx install mitmproxy` 3. `pipx install mitmproxy`

View File

@ -40,10 +40,7 @@ class Master:
# may want to spawn tasks during the initial configuration phase, # may want to spawn tasks during the initial configuration phase,
# which happens before run(). # which happens before run().
self.event_loop = event_loop or asyncio.get_running_loop() self.event_loop = event_loop or asyncio.get_running_loop()
try: self.should_exit = asyncio.Event()
self.should_exit = asyncio.Event()
except RuntimeError: # python 3.9 and below
self.should_exit = asyncio.Event(loop=self.event_loop) # type: ignore
mitmproxy_ctx.master = self mitmproxy_ctx.master = self
mitmproxy_ctx.log = self.log # deprecated, do not use. mitmproxy_ctx.log = self.log # deprecated, do not use.
mitmproxy_ctx.options = self.options mitmproxy_ctx.options = self.options

View File

@ -17,13 +17,9 @@ from collections.abc import Callable
from typing import Any from typing import Any
from typing import cast from typing import cast
from typing import Generic from typing import Generic
from typing import ParamSpec
from typing import TypeVar from typing import TypeVar
try:
from typing import ParamSpec
except ImportError: # pragma: no cover
# Python 3.9
from typing_extensions import ParamSpec # type: ignore
P = ParamSpec("P") P = ParamSpec("P")
R = TypeVar("R") R = TypeVar("R")

View File

@ -37,7 +37,6 @@ setup(
"Operating System :: POSIX", "Operating System :: POSIX",
"Operating System :: Microsoft :: Windows", "Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: CPython",
@ -70,7 +69,7 @@ setup(
"hook-dirs = mitmproxy.utils.pyinstaller:hook_dirs", "hook-dirs = mitmproxy.utils.pyinstaller:hook_dirs",
], ],
}, },
python_requires=">=3.9", python_requires=">=3.10",
# https://packaging.python.org/en/latest/discussions/install-requires-vs-requirements/#install-requires # https://packaging.python.org/en/latest/discussions/install-requires-vs-requirements/#install-requires
# It is not considered best practice to use install_requires to pin dependencies to specific versions. # It is not considered best practice to use install_requires to pin dependencies to specific versions.
install_requires=[ install_requires=[