Skip to content

Commit

Permalink
fix: strict type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Sep 17, 2022
1 parent 563b0a8 commit 36c14df
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ __pycache__/
dist/

# Cache
.pytest_cache/
.beet_cache/
.pytest_cache/
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ Create a new repository from this template by clicking the ["Use this template"]

You can also clone or download this repository manually, and rename the package and substitute all the `fixme` by hand. Don't forget to reset the version number and remove the one-off workflow in `.github/workflows/template.yml`.

## Conventional commits

The main workflow in `.github/workflows/main.yml` will take care of version bumps and releases automatically based on the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. This means that all commit messages must be prefixed with a type, such as `feat:`, `fix:`, `docs:`, etc. The type determines the version bump that will be applied to the package.

This will save you hours of fiddling with version numbers and changelogs.

To disable this feature, remove the "Release" step at the end of the main workflow. Then uninstall `python-semantic-release` with `poetry remove -Gdev python-semantic-release` and remove the `[tool.semantic_release]` section in `pyproject.toml`.

## Type checking

This template doesn't include a local static type checker, but if you use [Visual Studio Code](https://code.visualstudio.com/) the editor will directly report strong diagnostics thanks to the `typeCheckingMode = "strict"` option in `pyproject.toml`.

If you're more familiar with static typing in Python, you're encouraged to install [Pyright](https://github.com/microsoft/pyright) in the project to pin it to a specific version and run it after `pytest` in the main workflow.

## Publish on PyPI

To enable automatic releases on PyPI, [create a PyPI API token](https://pypi.org/manage/account/token/) and add it to your repository secrets as `PYPI_TOKEN`. Next, add the token as an environment variable at the end of the main workflow in `.github/workflows/main.yml`.
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ python-semantic-release = "^7.31.4"
[tool.pytest.ini_options]
addopts = "tests --import-mode=importlib"

[tool.pyright]
typeCheckingMode = "strict"

[tool.black]
target-version = ["py310"]

Expand Down

0 comments on commit 36c14df

Please sign in to comment.