From 5344bb088ae9ce02116810f907b9a0024b74d3a5 Mon Sep 17 00:00:00 2001 From: VovaVili Date: Tue, 26 Nov 2024 01:39:05 +0100 Subject: [PATCH] Refactor pytest and tox to use pyproject.toml --- pyproject.toml | 53 +++++++++++++++++++++++++++++++++++++++++- pytest.ini | 3 --- tox.ini | 62 -------------------------------------------------- 3 files changed, 52 insertions(+), 66 deletions(-) delete mode 100644 pytest.ini delete mode 100644 tox.ini diff --git a/pyproject.toml b/pyproject.toml index 0e2730a..551be54 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ dev = [ ] [tool.mypy] plugins = ['pydantic.mypy'] + [tool.ruff] line-length = 100 [tool.ruff.lint.pycodestyle] @@ -40,4 +41,54 @@ select = ["I", "D"] # These rules conflict with some other rules ignore = ["D203", "D213"] [tool.ruff.lint.per-file-ignores] -"__init__.py" = ["D104"] \ No newline at end of file +"__init__.py" = ["D104"] + +[tool.pytest.ini_options] +asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "module" + +[tool.tox] +min_version = "4.23.2" +env_list = ["py312", "lint", "type", "fix"] +requires = ["tox-uv>=1.16.0"] +isolated_build = true + +[tool.tox.env.default] +runner = "uv-venv-lock-runner" +description = "run unit tests" +deps = [ + "pytest>=8.3.3", + "pytest-cov>=6.0.0", +] +allowlist_externals = ["pytest"] +commands = ["pytest {posargs:tests} --cov --cov-report=xml"] + +[tool.tox.env.lint] +description = "run linters" +skip_install = true +deps = ["ruff>=0.7.4"] +allowlist_externals = ["ruff"] +commands = [ + "ruff check {posargs:.}", + "ruff format --check {posargs:.}", +] + +[tool.tox.env.type] +runner = "uv-venv-lock-runner" +description = "run type checks" +deps = ["mypy>=1.13.0"] +allowlist_externals = ["mypy"] +commands = ["mypy {posargs:src tests}"] + +[tool.tox.env.fix] +description = "run code formatter and linter (auto-fix)" +skip_install = true +deps = ["pre-commit-uv>=4.1.1"] +allowlist_externals = ["pre-commit"] +commands = ["pre-commit run --all-files --show-diff-on-failure"] + +[tool.tox.env.dev] +runner = "uv-venv-lock-runner" +description = "dev environment" +extras = ["dev", "test", "type"] +commands = ["uv pip tree"] \ No newline at end of file diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 22a99f5..0000000 --- a/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pytest] -asyncio_mode = auto -asyncio_default_fixture_loop_scope = module \ No newline at end of file diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 2f72915..0000000 --- a/tox.ini +++ /dev/null @@ -1,62 +0,0 @@ -[tox] -min_version = 4.23.2 -env_list = - py312 - lint - type - fix -requires = - tox-uv>=1.16.0 -isolated_build = True - -[testenv] -runner = uv-venv-lock-runner -description = run unit tests -deps = - pytest>=8.3.3 - pytest-cov>=6.0.0 -allowlist_externals = - pytest -commands = - pytest {posargs:tests} --cov --cov-report=xml - -[testenv:lint] -description = run linters -skip_install = true -deps = - ruff>=0.7.4 -allowlist_externals = - ruff -commands = - ruff check {posargs:.} - ruff format --check {posargs:.} - -[testenv:type] -runner = uv-venv-lock-runner -description = run type checks -deps = - mypy>=1.13.0 -allowlist_externals = - mypy -commands = - mypy {posargs:src tests} - -[testenv:fix] -description = run code formatter and linter (auto-fix) -skip_install = true -deps = - pre-commit-uv>=4.1.1 -allowlist_externals = - pre-commit -commands = - pre-commit run --all-files --show-diff-on-failure - -[testenv:dev] -runner = uv-venv-lock-runner -description = dev environment -extras = - dev - test - type -commands = - uv pip tree \ No newline at end of file