From 0dc790c513ac39180f78f5a7e6713908410c3abe Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Tue, 26 Sep 2023 10:18:48 -0700 Subject: Use Hatch to build and run tests/linters --- pyproject.toml | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 138 insertions(+), 12 deletions(-) (limited to 'pyproject.toml') diff --git a/pyproject.toml b/pyproject.toml index eed7728..508408b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" -#requires = ["hatchling"] -#build-backend = "hatchling.build" +#requires = ["setuptools"] +#build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" #requires = ["pdm-backend"] #build-backend = "pdm.backend" @@ -54,15 +54,141 @@ wikiget = "wikiget.wikiget:main" [tool.setuptools.dynamic] version = {attr = "wikiget.version.__version__"} -#[tool.hatch.version] -#path = "src/wikiget/version.py" +[tool.hatch.version] +path = "wikiget/version.py" #[tool.pdm] -#version = { source = "file", path = "src/wikiget/version.py" } +#version = { source = "file", path = "wikiget/version.py" } -[tool.pytest.ini_options] -addopts = [ - "--import-mode=importlib", - "--cov=wikiget", +#[tool.pytest.ini_options] +#addopts = [ +# "--import-mode=importlib", +# "--cov=wikiget", +#] +#testpaths = ["test"] + +[tool.hatch.envs.default] +dependencies = [ + "coverage[toml]>=6.5", + "pytest", +] +[tool.hatch.envs.default.scripts] +test = "pytest {args:test}" +test-cov = "coverage run -m pytest {args:test}" +cov-report = [ + "- coverage combine", + "coverage report", +] +cov = [ + "test-cov", + "cov-report", ] -testpaths = ["test"] + +[[tool.hatch.envs.all.matrix]] +python = ["3.7", "3.8", "3.9", "3.10", "3.11"] + +[tool.hatch.envs.lint] +detached = true +dependencies = [ + "black>=23.1.0", + "mypy>=1.0.0", + "ruff>=0.0.243", +] +[tool.hatch.envs.lint.scripts] +typing = "mypy --install-types --non-interactive {args:wikiget test}" +style = [ + "ruff {args:.}", + "black --check --diff {args:.}", +] +fmt = [ + "black {args:.}", + "ruff --fix {args:.}", + "style", +] +all = [ + "style", + "typing", +] + +[tool.black] +target-version = ["py37"] +line-length = 120 +skip-string-normalization = true + +[tool.ruff] +target-version = "py37" +line-length = 120 +select = [ + "A", + "ARG", + "B", + "C", + "DTZ", + "E", + "EM", + "F", + "FBT", + "I", + "ICN", + "ISC", + "N", + "PLC", + "PLE", + "PLR", + "PLW", + "Q", + "RUF", + "S", + "T", + "TID", + "UP", + "W", + "YTT", +] +ignore = [ + # Allow non-abstract empty methods in abstract base classes + "B027", + # Allow boolean positional values in function calls, like `dict.get(... True)` + "FBT003", + # Ignore checks for possible passwords + "S105", "S106", "S107", + # Ignore complexity + "C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915", +] +unfixable = [ + # Don't touch unused imports + "F401", +] + +[tool.ruff.isort] +known-first-party = ["wikiget"] + +[tool.ruff.flake8-tidy-imports] +ban-relative-imports = "all" + +[tool.ruff.per-file-ignores] +# Tests can use magic values, assertions, and relative imports +"test/**/*" = ["PLR2004", "S101", "TID252"] + +[tool.coverage.run] +source_pkgs = ["wikiget"] +branch = true +parallel = true +omit = [ + "wikiget/version.py", +] + +[tool.coverage.paths] +hatchtest = ["wikiget"] +tests = ["test"] + +[tool.coverage.report] +exclude_lines = [ + "no cov", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] + +[[tool.mypy.overrides]] +module = ["mwclient"] +ignore_missing_imports = true -- cgit v1.2.3 From a310af0aa10f8b5a370c16ac3a7dcdd12e13f729 Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Tue, 26 Sep 2023 10:45:58 -0700 Subject: Style fixups with Black --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'pyproject.toml') diff --git a/pyproject.toml b/pyproject.toml index 508408b..e0af5bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -112,12 +112,11 @@ all = [ [tool.black] target-version = ["py37"] -line-length = 120 -skip-string-normalization = true +line-length = 88 [tool.ruff] target-version = "py37" -line-length = 120 +line-length = 88 select = [ "A", "ARG", -- cgit v1.2.3 From 6bc21723d97a83f72fb1dc56a9c2db7e0e0cb36e Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Tue, 26 Sep 2023 11:04:55 -0700 Subject: Get rid of magic numbers for verbosity checking --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pyproject.toml') diff --git a/pyproject.toml b/pyproject.toml index e0af5bc..44f6d31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -153,6 +153,8 @@ ignore = [ "S105", "S106", "S107", # Ignore complexity "C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915", + # FIXME: temporarily ignore usage of `print()` + "T201", ] unfixable = [ # Don't touch unused imports -- cgit v1.2.3 From a20f56c2b62aee1d7b1aab989e9cdc2d5e2842af Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Tue, 26 Sep 2023 11:42:54 -0700 Subject: Remove version constraints from lint tools --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pyproject.toml') diff --git a/pyproject.toml b/pyproject.toml index 44f6d31..8b906c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,9 +90,9 @@ python = ["3.7", "3.8", "3.9", "3.10", "3.11"] [tool.hatch.envs.lint] detached = true dependencies = [ - "black>=23.1.0", - "mypy>=1.0.0", - "ruff>=0.0.243", + "black", + "mypy", + "ruff", ] [tool.hatch.envs.lint.scripts] typing = "mypy --install-types --non-interactive {args:wikiget test}" -- cgit v1.2.3