Skip to content

Commit

Permalink
add pdm scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
berislavlopac committed Feb 16, 2023
1 parent c6a7efe commit b5646d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
22 changes: 8 additions & 14 deletions CONTRIBUTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b5646d4

Please sign in to comment.