Skip to content

Commit

Permalink
Merge pull request #189 from billsioros/feat/additional-pre-commit-hooks
Browse files Browse the repository at this point in the history
feat: additional `pre-commit` hooks
  • Loading branch information
billsioros authored Jul 4, 2023
2 parents a9ea1de + e0ee59d commit 8200ef4
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 77 deletions.
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ENV ZSH="${HOME}/.oh-my-zsh"
RUN rm -rf ${ZSH}
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
RUN sed -i 's/ZSH_THEME=.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ${HOME}/.zshrc
RUN curl https://raw.githubusercontent.com/romkatv/powerlevel10k/master/config/p10k-classic.zsh > ${HOME}/.p10k.zsh

# Install Powerlevel10k theme
RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH/themes/powerlevel10k
Expand Down
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ repos:
hooks:
- id: check-github-workflows
- id: check-renovate
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.1
hooks:
- id: docformatter
additional_dependencies: [tomli]
exclude: tests
args: [--config, pyproject.toml]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
additional_dependencies: ["bandit[toml]"]
args: ["-c", "pyproject.toml"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 0.11.1
hooks:
- id: pyproject-fmt
args: [--indent, '2']
- repo: https://github.com/python-poetry/poetry
rev: 1.5.0
hooks:
Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ theme:
name: Switch to light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: green
accent: green
primary: teal
accent: teal
toggle:
icon: material/weather-sunny
name: Switch to dark mode
Expand Down
55 changes: 35 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = [
"poetry-core>=1",
]

[tool.black]
line-length = 99
target-version = ["py37", "py38"]
skip-string-normalization = true
exclude = "{{cookiecutter.project_name}}"

[tool.isort]
profile = "black"
src_paths = ["cookiecutter-pypackage", "hooks", "tests"]
line_length = 99

[tool.pytest.ini_options]
addopts = "-vv --color=yes"
log_cli = false
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
log_cli_format = "%(asctime)s %(levelname)s %(message)s"
log_cli_level = "INFO"
python_files = "test_*.py"
python_functions = "test_*"
testpaths = "tests"

[tool.poetry]
name = "cookiecutter-pypackage"
Expand Down Expand Up @@ -58,23 +81,15 @@ lint = { cmd = "poetry run ruff check src", help = "Lint your code for errors" }
docs = { shell = "python -c 'import webbrowser; webbrowser.open(\"http://127.0.0.1:8000\")'; poetry run mkdocs serve", help = "Build and serve the documentation" }
export = { cmd = "poetry export --without-hashes --dev -o requirements.txt" }

[tool.pytest.ini_options]
addopts = "-vv --color=yes"
log_cli = false
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
log_cli_format = "%(asctime)s %(levelname)s %(message)s"
log_cli_level = "INFO"
python_files = "test_*.py"
python_functions = "test_*"
testpaths = "tests"

[tool.isort]
profile = "black"
src_paths = ["cookiecutter-pypackage", "hooks", "tests"]
line_length = 99
[tool.docformatter]
black = true
non-strict = true
non-cap = [
"cookiecutter-pypackage",
]
recursive = true
in-place = true

[tool.black]
line-length = 99
target-version = ["py37", "py38"]
skip-string-normalization = true
exclude = "{{cookiecutter.project_name}}"
[tool.bandit]
recursive = true
exclude_dirs = ["tests"]
24 changes: 18 additions & 6 deletions {{cookiecutter.project_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ repos:
- id: interrogate
args: [-v, --fail-under=100]
files: ^src/
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
files: ^src/
additional_dependencies: [toml]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand Down Expand Up @@ -89,6 +83,24 @@ repos:
hooks:
- id: check-github-workflows
- id: check-renovate
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.1
hooks:
- id: docformatter
additional_dependencies: [tomli]
exclude: tests
args: [--config, pyproject.toml]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
additional_dependencies: ["bandit[toml]"]
args: ["-c", "pyproject.toml"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 0.11.1
hooks:
- id: pyproject-fmt
args: [--indent, '2']
- repo: https://github.com/google/yamlfmt
rev: v0.9.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions {{cookiecutter.project_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ poetry install

# Install pre-commit hooks
pre-commit install --install-hooks
pre-commit autoupdate
```

## :book: Documentation
Expand Down
112 changes: 63 additions & 49 deletions {{cookiecutter.project_name}}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = [
"poetry-core>=1",
]

[tool.black]
line-length = 99
target-version = ["py37", "py38"]
skip-string-normalization = true

[tool.isort]
profile = "black"
src_paths = ["src/{{cookiecutter.package_name}}", "tests"]
line_length = 99
known_first_party = "{{cookiecutter.package_name}}"

[tool.pytest.ini_options]
addopts = "-vv --color=yes"
log_cli = false
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
log_cli_format = "%(asctime)s %(levelname)s %(message)s"
log_cli_level = "INFO"
python_files = "test_*.py"
python_functions = "test_*"
testpaths = "tests"

[tool.coverage.paths]
source = ["src"]

[tool.coverage.run]
branch = true
source = ["{{cookiecutter.package_name}}"]

[tool.coverage.report]
show_missing = true
fail_under = 100
exclude_lines = ["if self.debug:", "pragma: no cover", "raise NotImplementedError", "if __name__ == .__main__.:"]
ignore_errors = true
omit = ["tests/*"]

[tool.mypy]
files = ["src/{{cookiecutter.package_name}}"]
warn_unused_configs = true
warn_return_any = true
ignore_missing_imports = true
pretty = true
color_output = true
show_column_numbers = true
show_error_codes = true
show_error_context = true
strict = true

[tool.poetry]
name = "{{cookiecutter.project_name}}"
Expand Down Expand Up @@ -66,54 +115,6 @@ lint = { cmd = "poetry run ruff check src", help = "Lint your code for errors" }
docs = { shell = "python -c 'import webbrowser; webbrowser.open(\"http://127.0.0.1:8000\")'; poetry run mkdocs serve", help = "Build and serve the documentation" }
export = { cmd = "poetry export --without-hashes --dev -o requirements.txt" }

[tool.pytest.ini_options]
addopts = "-vv --color=yes"
log_cli = false
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
log_cli_format = "%(asctime)s %(levelname)s %(message)s"
log_cli_level = "INFO"
python_files = "test_*.py"
python_functions = "test_*"
testpaths = "tests"

[tool.coverage.paths]
source = ["src"]

[tool.coverage.run]
branch = true
source = ["{{cookiecutter.package_name}}"]

[tool.coverage.report]
show_missing = true
fail_under = 100
exclude_lines = ["if self.debug:", "pragma: no cover", "raise NotImplementedError", "if __name__ == .__main__.:"]
ignore_errors = true
omit = ["tests/*"]

[tool.isort]
profile = "black"
src_paths = ["src/{{cookiecutter.package_name}}", "tests"]
line_length = 99
known_first_party = "{{cookiecutter.package_name}}"

[tool.black]
line-length = 99
target-version = ["py37", "py38"]
skip-string-normalization = true

[tool.mypy]
files = ["src/{{cookiecutter.package_name}}"]
warn_unused_configs = true
warn_return_any = true
ignore_missing_imports = true
pretty = true
color_output = true
show_column_numbers = true
show_error_codes = true
show_error_context = true
strict = true


[tool.ruff]
select = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
ignore = []
Expand Down Expand Up @@ -160,3 +161,16 @@ convention = "google"

[tool.ruff.flake8-quotes]
docstring-quotes = "double"

[tool.docformatter]
black = true
non-strict = true
non-cap = [
"{{cookiecutter.package_name}}",
]
recursive = true
in-place = true

[tool.bandit]
recursive = true
exclude_dirs = ["tests"]

0 comments on commit 8200ef4

Please sign in to comment.