From b5646d4fd579a2e2d2d0dbc40f11c69032891777 Mon Sep 17 00:00:00 2001 From: Berislav Lopac Date: Thu, 16 Feb 2023 10:59:41 +0000 Subject: [PATCH] add pdm scripts --- CONTRIBUTE.md | 22 ++++++++-------------- pyproject.toml | 12 ++++++++++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index 22d275c..a84e7dc 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -29,30 +29,24 @@ $ pyenv install 3.9.12 $ pyenv install 3.10.4 $ pyenv local 3.8.13 3.9.12 3.10.4 ``` -This is not needed for the CI, which runs one Python version (image) at a time. #### Manual Validation -During development, each code check can be executed independently: +There is a number of code quality checks that can be executed using PDM commands: ```shell -$ ruff . # code linting -$ mypy --install-types --non-interactive momoa/ # Python typing analysis -$ black --check . # Python code formatting -$ isort --check . # Import statement optimisation -$ pydocstyle momoa/ # styling and completeness of docstrings +$ pdm run check-lint # validates code linting using tools like ruff, black or isort +$ pdm run check-typing # runs static type analysis using mypy +$ pdm run check-docs # checks docstring content and structure +$ pdm run checks # runs all of the above checks together ``` -For unit tests use: +There is a separate command for running tests: ```shell -$ pytest --cov --spec +$ pdm run tests ``` - -The indicated options add extra details to the report: - -* `--cov` adds a test coverage report -* `--spec` formats the test report as a list of spec statements +Of course, tests can also be executed using `pytest` directly. ## API Documentation diff --git a/pyproject.toml b/pyproject.toml index 9992538..f9d6d23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,18 @@ checks = [ "ruff>=0.0.238", ] +[tool.pdm.scripts] +tests.cmd = "pytest --spec --cov" +check-lint.shell = """ + ruff . + black --check . + isort --check . +""" +check-typing.cmd = "mypy --install-types --non-interactive momoa/" +check-docs.cmd = "pydocstyle momoa/" +checks.composite = ["check-lint", "check-typing", "check-docs"] +new-commits.shell = "git log $(git describe --tags --abbrev=0)..HEAD --oneline --no-decorate" + [project.urls] homepage = "https://momoa.readthedocs.io" repository = "https://github.com/berislavlopac/momoa"