Skip to content

Commit 7198d5d

Browse files
Remove pytest and coverage as push hooks (#6)
* Removed the pytest and coverage push hooks from bein added as I need a way to skip coverage if no tests are found * pass_filenames=false for flake8 to run only instance and fixing up pyproject.toml
1 parent 0f2accb commit 7198d5d

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ repos:
3131
name: Running flake8 from local poetry env
3232
entry: poetry run flake8 .
3333
language: system
34+
pass_filenames: false
3435
files: ".*.py"
3536
exclude: "{{ cookiecutter.project_slug }}"
3637
- id: isort

setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ exclude =
44
.git,
55
# There's no value in checking cache directories
66
__pycache__,
7-
# Don't check virtualenv
7+
# No need to look in the virtual env folder
8+
.env,
9+
.venv/,
810
venv/,
9-
.venv/
1011
max_line_length = 100
1112
# B001 is already enabled for flake8-bugbear
1213
extend-ignore = E722

{{ cookiecutter.project_slug }}/.pre-commit-config.yaml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ repos:
3030
name: Running flake8 from local poetry env
3131
entry: poetry run flake8 .
3232
language: system
33+
pass_filenames: false
3334
files: ".*.py"
3435
- id: isort
3536
name: Running isort from local poetry env
@@ -42,22 +43,3 @@ repos:
4243
# Max 7 arguments allowed, show only warnings, sort by CCN, exclude .venv
4344
args: ["--CCN", "8", "-a", "7", "-w", "-s", "cyclomatic_complexity", "-x", ".\\.venv\\*"]
4445
language: python
45-
{% if cookiecutter.pytest == "y" -%}
46-
- id: pytest
47-
name: Running tests using pytest from local poetry env
48-
entry: poetry run coverage run -m pytest
49-
args: ["-x"]
50-
language: system
51-
types:
52-
- python
53-
pass_filenames: false
54-
stages: [push]
55-
- id: coverage
56-
name: Generating coverage report
57-
entry: poetry run coverage report -m
58-
language: system
59-
types:
60-
- python
61-
pass_filenames: false
62-
stages: [push]
63-
{%- endif %}

{{ cookiecutter.project_slug }}/pyproject.toml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,27 @@ quiet = true
3939
plugins = ["covdefaults"]
4040

4141
[tool.coverage.report]
42+
branch = true
4243
fail_under = 95
4344
omit = [
44-
"logger.py"
45+
"logger.py",
46+
"*/tests/*",
47+
]
48+
exclude_lines = [
49+
# Have to re-enable the standard pragma
50+
"pragma: no cover",
51+
52+
# Don't complain about missing debug-only code:
53+
"def __repr__",
54+
"if self\.debug",
55+
56+
# Don't complain if tests don't hit defensive assertion code:
57+
"raise AssertionError",
58+
"raise NotImplementedError",
59+
60+
# Don't complain if non-runnable code isn't run:
61+
"if 0:",
62+
"if __name__ == .__main__.:",
4563
]
4664
{%- endif %}
4765

{{ cookiecutter.project_slug }}/setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ exclude =
44
.git,
55
# There's no value in checking cache directories
66
__pycache__,
7-
# Don't check virtualenv
7+
# No need to look in the virtual env folder
8+
.env,
9+
.venv/,
810
venv/,
9-
.venv/
1011
max_line_length = 100
1112
# B001 is already enabled for flake8-bugbear
1213
extend-ignore = E722

0 commit comments

Comments
 (0)