Skip to content

Commit

Permalink
remove interrogate tool because it is unmaintained, closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
a.pirogov committed Jun 15, 2023
1 parent b79836c commit fd254fd
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 47 deletions.
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ repos:
- id: pydocstyle
additional_dependencies: ["tomli==2.0.1"]
files: "^src/"
- repo: https://github.com/econchick/interrogate
rev: "1.5.0"
hooks:
- id: interrogate
files: "^src/"

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.1.1'
hooks:
Expand Down
8 changes: 4 additions & 4 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"audience": [
{
"@type": "Audience",
"audienceType": "Science/Research"
"audienceType": "Developers"
},
{
"@type": "Audience",
"audienceType": "Developers"
"audienceType": "Science/Research"
}
],
"author": [
Expand Down Expand Up @@ -44,7 +44,7 @@
"identifier": "cookiecutter",
"name": "cookiecutter",
"runtimePlatform": "Python 3",
"version": "^2.1.1"
"version": "^2.1.2"
},
{
"@type": "SoftwareApplication",
Expand All @@ -55,4 +55,4 @@
}
],
"version": "0.1.0"
}
}
2 changes: 1 addition & 1 deletion hooks/post_gen_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rm tests/test_api.py

# finalize repo setup
git init
poetry install
poetry install --with docs
poetry run poe init-dev # init git repo + register pre-commit
poetry run pip install pipx # install pipx into venv without adding it as dep
poetry run pipx run reuse download --all # get license files for REUSE compliance
Expand Down
44 changes: 38 additions & 6 deletions tests/test_template.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
import subprocess
import sys

import pytest
from cookiecutter.exceptions import CookiecutterException
from cookiecutter.main import cookiecutter


def sanity_check_project(proj_path):
"""Sanity-check a generated project (linters, tests, doc generation)."""
subprocess.check_call("poetry install --with docs".split(), cwd=proj_path)
subprocess.check_call("poetry run poe lint --all-files".split(), cwd=proj_path)
subprocess.check_call("poetry run poe test".split(), cwd=proj_path)
subprocess.check_call("poetry run poe docs".split(), cwd=proj_path)
try:
subprocess.check_output(
"poetry install --with docs".split(), cwd=proj_path, stderr=subprocess.PIPE
)
subprocess.check_output(
"poetry run poe lint --all-files".split(),
cwd=proj_path,
stderr=subprocess.PIPE,
)
subprocess.check_output(
"poetry run poe test".split(), cwd=proj_path, stderr=subprocess.PIPE
)
subprocess.check_output(
"poetry run poe docs".split(), cwd=proj_path, stderr=subprocess.PIPE
)
except subprocess.CalledProcessError as e:
print("exit code: {}".format(e.returncode))
print("stderr: {}".format(e.stderr.decode(sys.getfilesystemencoding())))


@pytest.fixture
Expand All @@ -23,9 +39,25 @@ def gen(tmp_path_factory):

def gen_project(**cc_args):
out_dir = tmp_path_factory.mktemp("gen_proj")
out_dir_raw = tmp_path_factory.mktemp("gen_proj_raw")

# actual project generation
cookiecutter(template="./", no_input=True, output_dir=out_dir, **cc_args)
# NOTE: once 2.1.2 is out with keep_project_on_failure,
# this can be simplified
# instantiate without hooks (for debugging)
cookiecutter(
template="./",
no_input=True,
output_dir=out_dir_raw,
accept_hooks=False,
**cc_args,
)

# actual project generation (with hooks)
try:
cookiecutter(template="./", no_input=True, output_dir=out_dir, **cc_args)
except CookiecutterException as e:
print(f"DEBUG DIR (without hook evaluation): {out_dir_raw}")
raise e

# should be unique directory
paths = list(out_dir.iterdir())
Expand Down
5 changes: 0 additions & 5 deletions {{ cookiecutter.__project_slug }}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ repos:
- id: pydocstyle
additional_dependencies: ["tomli==2.0.1"]
files: "^src/"
- repo: https://github.com/econchick/interrogate
rev: "1.5.0"
hooks:
- id: interrogate
files: "^src/"
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.1.1'
hooks:
Expand Down
4 changes: 0 additions & 4 deletions {{ cookiecutter.__project_slug }}/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
![Project status](https://img.shields.io/badge/project%20status-alpha-%23ff8000)
[
![Docs](https://img.shields.io/badge/read-docs-success)
]({{ cookiecutter.__project_gh_pages }})
Expand All @@ -8,9 +7,6 @@
[
![Test Coverage]({{ cookiecutter.__project_gh_pages }}/main/coverage_badge.svg)
]({{ cookiecutter.__project_gh_pages }}/main/coverage)
[
![Docs Coverage]({{ cookiecutter.__project_gh_pages }}/main/interrogate_badge.svg)
]({{ cookiecutter.__project_gh_pages }})

<!-- --8<-- [start:abstract] -->
# {{ cookiecutter.project_name.strip() }}
Expand Down
19 changes: 6 additions & 13 deletions {{ cookiecutter.__project_slug }}/docs/scripts/coverage_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
import anybadge
import pytest
from coverage import Coverage
from interrogate import badge_gen
from interrogate.coverage import InterrogateCoverage

log = logging.getLogger("mkdocs")


badge_colors = {
20: "red",
40: "orange",
60: "yellow",
80: "greenyellow",
90: "green",
20.0: "red",
40.0: "orange",
60.0: "yellow",
80.0: "greenyellow",
90.0: "green",
}
"""Colors for overall coverage percentage (0-100)."""


def on_pre_build(config):
def on_pre_build(_config):
"""Generate coverage report if it is missing and create a badge."""
if not Path("htmlcov").is_dir() or not Path(".coverage").is_file():
log.info("Missing htmlcov or .coverage, running pytest to collect.")
Expand All @@ -47,8 +45,3 @@ def on_pre_build(config):
if badge_svg.is_file():
badge_svg.unlink()
badge.write_badge(badge_svg)

# generates a docs coverage badge in docs/interrogate_badge.svg
doc_cov = InterrogateCoverage(paths=["src"]).get_coverage()
log.info(f"Docs Coverage: {doc_cov.perc_covered}%, generating badge.")
badge_gen.create("docs", doc_cov)
12 changes: 3 additions & 9 deletions {{ cookiecutter.__project_slug }}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ classifiers = [
# TODO: update the classifier strings
# (see https://pypi.org/classifiers/)
"Operating System :: POSIX :: Linux",
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
]
Expand All @@ -27,10 +26,9 @@ packages = [{include = "{{ cookiecutter.__project_package }}", from = "src"}]
# include files related to test and documentation only in sdist:
include = [
"*.md", "LICENSE", "LICENSES", ".reuse/dep5", "CITATION.cff", "codemeta.json",
"mkdocs.yml", "docs", "tests", # NOTE: temporary workaround (codemetapy bug)
# { path = "mkdocs.yml", format = "sdist" },
# { path = "docs", format = "sdist" },
# { path = "tests", format = "sdist" },
{ path = "mkdocs.yml", format = "sdist" },
{ path = "docs", format = "sdist" },
{ path = "tests", format = "sdist" },
]

[tool.poetry.dependencies]
Expand Down Expand Up @@ -71,7 +69,6 @@ markdown-exec = {extras = ["ansi"], version = "^1.6.0"}
mkdocs-coverage = "^0.2.7"
mike = "^1.1.2"
anybadge = "^1.14.0"
interrogate = "^1.5.0"
black = "^23.3.0"

[tool.poetry.scripts]
Expand Down Expand Up @@ -129,9 +126,6 @@ max-line-length = 88
[tool.pydocstyle]
convention = "google"

[tool.interrogate]
fail-under = 95

[tool.bandit]
exclude_dirs = ["tests", "scripts"]

Expand Down

0 comments on commit fd254fd

Please sign in to comment.