Skip to content

Commit 046317b

Browse files
authored
Merge pull request #13 from febus982/pre-commit
Adds pre-commit configuration
2 parents 124bc33 + 373a437 commit 046317b

File tree

12 files changed

+47
-13
lines changed

12 files changed

+47
-13
lines changed

.bandit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ any_other_function_with_shell_equals_true:
134134
- subprocess.run
135135
assert_used:
136136
skips:
137+
- tests/*.py
137138
- ./tests/*.py
138139
hardcoded_tmp_directory:
139140
tmp_dirs:

.github/workflows/python-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ jobs:
3636
- name: Check typing
3737
run: |
3838
make typing
39-

.idea/bootstrap-python-package.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Pytest.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.pre-commit-config.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- id: debug-statements
12+
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
13+
- repo: https://github.com/psf/black-pre-commit-mirror
14+
rev: 23.12.1
15+
hooks:
16+
- id: black
17+
# It is recommended to specify the latest version of Python
18+
# supported by your project here, or alternatively use
19+
# pre-commit's default_language_version, see
20+
# https://pre-commit.com/#top_level-default_language_version
21+
language_version: python3.12
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
# Ruff version.
24+
rev: v0.1.14
25+
hooks:
26+
# Run the linter.
27+
- id: ruff
28+
args: [ --fix ]
29+
# Run the formatter.
30+
#- id: ruff-format

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ It is configured with all the following features:
2828
* GitHub pages documentation using [mkdocs](https://www.mkdocs.org)
2929

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

3434
## How to use this repository template to create a new package
@@ -41,14 +41,16 @@ previous python versions directly in the CI pipeline.
4141
* Owner: The github repository owner (in this case `febus982`)
4242
* Repository name: The github repository name (in this case `bootstrap-python-package`)
4343
* Workflow name: `release.yml`
44-
* Create a GitHub Actions secret named `CODECLIMATE_REPORTER_ID` (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/secrets/actions`)
44+
* Create a GitHub Actions secret named `CODECLIMATE_REPORTER_ID` (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/secrets/actions`)
4545
containing the codeclimate reporter id (you can find it at `https://codeclimate.com/repos/YOUR_REPO_ID/settings/test_reporter`).
4646
If you don't want to use CodeClimate just delete `workflows/python-quality.yml`.
4747
* Update the badges in `README.md`! (check [shields.io](https://shields.io/) for extra badges)
4848
* Setup local development:
4949
* Clone the repository
5050
* Install poetry `pip install poetry`
5151
* Install dev dependencies with `make dev-dependencies`
52+
* (optional) It is strongly recommended to install [pre-commit](https://pre-commit.com/#installation)
53+
and run `pre-commit install` so that formatting and linting are automatically executed during `git commit`.
5254
* Setup GitHub pages (this need local development setup):
5355
* Initialise documentation branch `poetry run mike deploy dev latest --update-aliases --push`
5456
* Configure GitHub Pages to deploy from the `gh-pages` branch (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/pages`)

docs/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ It is configured with all the following features:
1515
* GitHub pages documentation using [mkdocs](https://www.mkdocs.org)
1616

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

2121
## How to use this repository template to create a new package
@@ -28,14 +28,16 @@ previous python versions directly in the CI pipeline.
2828
* Owner: The github repository owner (in this case `febus982`)
2929
* Repository name: The github repository name (in this case `bootstrap-python-package`)
3030
* Workflow name: `release.yml`
31-
* Create a GitHub Actions secret named `CODECLIMATE_REPORTER_ID` (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/secrets/actions`)
31+
* Create a GitHub Actions secret named `CODECLIMATE_REPORTER_ID` (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/secrets/actions`)
3232
containing the codeclimate reporter id (you can find it at `https://codeclimate.com/repos/YOUR_REPO_ID/settings/test_reporter`).
3333
If you don't want to use CodeClimate just delete `workflows/python-quality.yml`.
3434
* Update the badges in `README.md`! (check [shields.io](https://shields.io/) for extra badges)
3535
* Setup local development:
3636
* Clone the repository
3737
* Install poetry `pip install poetry`
3838
* Install dev dependencies with `make dev-dependencies`
39+
* (optional) It is strongly recommended to install [pre-commit](https://pre-commit.com/#installation)
40+
and run `pre-commit install` so that formatting and linting are automatically executed during `git commit`.
3941
* Setup GitHub pages (this need local development setup):
4042
* Initialise documentation branch `poetry run mike deploy dev latest --update-aliases --push`
4143
* Configure GitHub Pages to deploy from the `gh-pages` branch (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/pages`)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ bandit = ">=1.7.6"
4646
black = ">=22.10.0"
4747
mkdocs = ">=1.4.3"
4848
mkdocstrings = { version = ">=0.24.0", extras = ["python"] }
49+
mkdocs-gen-files = ">=0.5.0"
4950
mkdocs-material = ">=9.1.16"
5051
mike = ">=2.0.0"
5152
mypy = ">=0.990"
@@ -56,7 +57,6 @@ pytest-cov = ">=4.0.0"
5657
pytest-factoryboy = ">=2.5.0"
5758
pytest-xdist = ">=3.0.2"
5859
ruff = ">=0.0.263"
59-
mkdocs-gen-files = "^0.5.0"
6060

6161
[tool.pytest.ini_options]
6262
asyncio_mode = "auto"
@@ -76,13 +76,13 @@ concurrency = ["multiprocessing"]
7676
parallel = true
7777

7878
[tool.coverage.report]
79+
fail_under = 100
7980
exclude_also = [
8081
"pragma: no cover",
8182
"pass",
8283
"\\.\\.\\.",
8384
]
8485

85-
8686
[tool.ruff]
8787
select = ["E", "F", "I"]
8888
extend-exclude = ["docs"]

0 commit comments

Comments
 (0)