Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ skips:
### provided. It is not necessary to provide settings for every (or any) plugin
### if the defaults are acceptable.

exclude_dirs: ['.tox']

any_other_function_with_shell_equals_true:
no_shell:
- os.execl
Expand Down
3 changes: 2 additions & 1 deletion .idea/bootstrap-python-package.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/runConfigurations/Tox.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ ci-coverage:
poetry run pytest --cov --cov-report lcov

typing:
poetry run mypy
tox -e typing

format:
poetry run black --check .
tox -e format

lint:
poetry run ruff .
tox -e lint

bandit:
poetry run bandit -c .bandit.yml -r .
tox -e bandit

format-fix:
poetry run black .
Expand All @@ -34,7 +34,8 @@ update-dependencies:
poetry update --with dev

fix: format-fix lint-fix
check: typing format lint test bandit
check:
tox

docs:
poetry run mkdocs serve
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
This template repository provides the boilerplate to create a python package.
It is configured with all the following features:

* Test suite using [pytest](https://docs.pytest.org/en/7.4.x/)
* Test suite using [tox](https://tox.wiki/en/latest/index.html) and [pytest](https://docs.pytest.org/en/7.4.x/)
* Typing using [mypy](https://mypy.readthedocs.io/en/stable/)
* Linting using [ruff](https://github.com/astral-sh/ruff)
* Code formatter using [black](https://pypi.org/project/black/)
Expand All @@ -27,10 +27,6 @@ It is configured with all the following features:
* releases on [PyPI](https://pypi.org)
* GitHub pages documentation using [mkdocs](https://www.mkdocs.org)

This project doesn't currently use [tox](https://tox.wiki/en/4.11.4/index.html) or other matrix
testing utilities. I prefer to run the tests only against the latest python locally, and run
previous python versions directly in the CI pipeline.

## How to use this repository template to create a new package

* Create your github repository using this template. (The big green `Use this template` button)
Expand Down Expand Up @@ -84,7 +80,8 @@ All the common commands used during development can be run using make targets:

* `make dev-dependencies`: Install dev requirements
* `make update-dependencies`: Update dev requirements
* `make test`: Run test suite
* `make check`: Run tests, code style and lint checks
* `make fix`: Run code style and lint automatic fixes (where possible)
* `make test`: Run test suite against system python version
* `make check`: Run tests against all available python versions, code style and lint checks
* `make type`, `make format`, `make lint`, `make bandit`: Run the relevant check
* `make docs`: Render the mkdocs website locally
9 changes: 3 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ It is configured with all the following features:
* releases on [PyPI](https://pypi.org)
* GitHub pages documentation using [mkdocs](https://www.mkdocs.org)

This project doesn't currently use [tox](https://tox.wiki/en/4.11.4/index.html) or other matrix
testing utilities. I prefer to run the tests only against the latest python locally, and run
previous python versions directly in the CI pipeline.

## How to use this repository template to create a new package

* Create your github repository using this template. (The big green `Use this template` button)
Expand Down Expand Up @@ -71,7 +67,8 @@ All the common commands used during development can be run using make targets:

* `make dev-dependencies`: Install dev requirements
* `make update-dependencies`: Update dev requirements
* `make test`: Run test suite
* `make check`: Run tests, code style and lint checks
* `make fix`: Run code style and lint automatic fixes (where possible)
* `make test`: Run test suite against system python version
* `make check`: Run tests against all available python versions, code style and lint checks
* `make type`, `make format`, `make lint`, `make bandit`: Run the relevant check
* `make docs`: Render the mkdocs website locally
53 changes: 33 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ classifiers = [
]

[tool.poetry-dynamic-versioning]
enable = true
enable = false

[build-system]
requires = ["poetry-core", "poetry-dynamic-versioning"]
build-backend = "poetry_dynamic_versioning.backend"

############################
### Package requirements ###
############################

[tool.poetry.dependencies]
python = ">=3.8,<3.13"

Expand All @@ -57,17 +61,20 @@ pytest-cov = ">=4.0.0"
pytest-factoryboy = ">=2.5.0"
pytest-xdist = ">=3.0.2"
ruff = ">=0.0.263"
tox = ">=4.12.1"

[tool.pytest.ini_options]
asyncio_mode = "auto"
minversion = "6.0"
addopts = "-n auto --cov-report=term-missing"
testpaths = [
"tests",
]
############################
### Tools configuration ###
############################

[tool.mypy]
files = "bootstrap_python_package"
[tool.black]
target-version = ["py38", "py39", "py310", "py311", "py312"]
extend-exclude = '''
(
/docs,
.tox
)
'''

[tool.coverage.run]
branch = true
Expand All @@ -83,17 +90,23 @@ exclude_also = [
"\\.\\.\\.",
]

[tool.mypy]
files = "bootstrap_python_package"
python_version = "3.8"

[tool.pytest.ini_options]
asyncio_mode = "auto"
minversion = "6.0"
addopts = "-n auto --cov-report=term-missing"
testpaths = [
"tests",
]

[tool.ruff]
extend-exclude = ["docs", ".tox"]

[tool.ruff.lint]
select = ["E", "F", "I"]
extend-exclude = ["docs"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]

[tool.black]
target-version = ["py38", "py39", "py310", "py311", "py312"]
extend-exclude = '''
(
/docs
)
'''
52 changes: 52 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[tox]
min_version = 4.0
env_list =
py312
py311
py310
py39
py38
typing
format
lint
bandit

[testenv]
allowlist_externals = poetry, pytest
; Poetry is really bad in identifying running virtualenvs, so we can't use
; directly poetry install. This is the best hacky way to install poetry
; requirements inside tox.
commands_pre =
poetry export -f requirements.txt --output /tmp/requirements.txt --with dev
pip install -Uqr /tmp/requirements.txt
commands =
pytest

[testenv:py312]
; Run with coverage in one python version to check coverage percentage
commands =
pytest --cov

[testenv:typing]
allowlist_externals = poetry, mypy
; commands_pre is inherited from testenv
commands =
mypy

[testenv:format]
allowlist_externals = poetry, black
; commands_pre is inherited from testenv
commands =
black --check .

[testenv:lint]
allowlist_externals = poetry, ruff
; commands_pre is inherited from testenv
commands =
ruff .

[testenv:bandit]
allowlist_externals = poetry, bandit
; commands_pre is inherited from testenv
commands =
bandit -c .bandit.yml -r .