From f3fc2770ac3a11462d3d8d8bb5e4962f2121e867 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Mon, 18 Nov 2024 15:23:10 +0000 Subject: [PATCH] Require python 3.9 and support 3.13 (#114) --- .github/workflows/tox.yml | 7 +++---- .pre-commit-config.yaml | 1 + bindep.txt | 0 mypy.ini | 14 -------------- pyproject.toml | 15 +++++++++++++-- src/tox_extra/hooks.py | 19 +++++++++++-------- tox.ini | 1 + 7 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 bindep.txt delete mode 100644 mypy.ini diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index a82abfc..5d0796b 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -35,19 +35,18 @@ jobs: id: generate_matrix uses: coactions/dynamic-matrix@v4 with: - min_python: "3.8" + min_python: "3.9" max_python: "3.13" default_python: "3.10" other_names: | lint pkg - py38:tox -e py38 py39:tox -e py39 py310:tox -e py310; tox -e py310-devel py311:tox -e py311; tox -e py311-devel py312:tox -e py312; tox -e py312-devel - py313:tox -e py313-devel - py312-macos:tox -e py312; tox -e py312-devel + py313:tox -e py312; tox -e py313-devel + py313-macos:tox -e py313; tox -e py313-devel platforms: linux,macos skip_explode: "1" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ab2e843..a8e3361 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,6 +53,7 @@ repos: - gitpython - packaging - py>=1.9.0 + - tox>=4.23.2 - repo: https://github.com/pre-commit/mirrors-pylint rev: v3.0.0a5 hooks: diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..e69de29 diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 0352f8b..0000000 --- a/mypy.ini +++ /dev/null @@ -1,14 +0,0 @@ -[mypy] -python_version = 3.8 -color_output = True -error_summary = True -disallow_untyped_calls = True -warn_redundant_casts = True -no_implicit_optional = True - -# 3rd party ignores, to remove once they add hints -[mypy-tox.*] -ignore_missing_imports = True - -[mypy-git.*] -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index c93ec90..5f6861c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] # https://peps.python.org/pep-0621/#readme -requires-python = ">=3.8" +requires-python = ">=3.9" dynamic = ["version"] name = "tox-extra" description = "Performs extra checks before or after running" @@ -26,11 +26,11 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Testing" ] keywords = ["git", "tox", "tox-plugin"] @@ -74,5 +74,16 @@ parallel = true [tool.isort] profile = "black" +[tool.mypy] +python_version = 3.9 +color_output = true +error_summary = true +disallow_untyped_calls = true +disallow_untyped_defs = true +disallow_any_generics = true + +[tool.pytest.ini_options] +addopts = "-ra --showlocals" + [tool.setuptools_scm] local_scheme = "no-local-version" diff --git a/src/tox_extra/hooks.py b/src/tox_extra/hooks.py index cdc2eda..0f2088d 100644 --- a/src/tox_extra/hooks.py +++ b/src/tox_extra/hooks.py @@ -13,6 +13,7 @@ from tox.plugin import impl from tox.tox_env.api import ToxEnv from tox.tox_env.errors import Fail +from tox.tox_env.python.api import Python from tox_extra.bindep import check_bindep @@ -58,17 +59,19 @@ def tox_add_option(parser: ArgumentParser) -> None: # pylint: disable=unused-argument def tox_on_install(tox_env: ToxEnv, arguments: Any, section: str, of_type: str) -> None: """Runs just before installing package.""" - profiles = frozenset( - [ + if os.environ.get("TOX_EXTRA_BINDEP", "1") != "0": + profiles = { "test", - f"python{tox_env.py_dot_ver()}", # python3.12 like profile - f"py{tox_env.py_dot_ver().replace('.', '')}", # py312 like profile tox_env.name, # exact tox env name, useful for stuff like 'docs' or 'lint' *tox_env.name.split("-"), - ] - ) - if os.environ.get("TOX_EXTRA_BINDEP", "1") != "0": - check_bindep(path=pathlib.Path.cwd(), profiles=profiles) + } + if isinstance(tox_env, Python): + profiles.add(f"python{tox_env.py_dot_ver()}") # python3.12 like profile + profiles.add( + f"py{tox_env.py_dot_ver().replace('.', '')}" + ) # py312 like profile # type: ignore + + check_bindep(path=pathlib.Path.cwd(), profiles=frozenset(profiles)) @impl diff --git a/tox.ini b/tox.ini index 092881a..0ef7de9 100644 --- a/tox.ini +++ b/tox.ini @@ -51,6 +51,7 @@ usedevelop = false skip_install = true deps = build >= 0.9.0 + pip twine >= 4.0.1 setenv = commands =