Skip to content

Commit 921fe53

Browse files
Modernize template. (#35)
1 parent 651612a commit 921fe53

27 files changed

+208
-304
lines changed

.github/workflows/main.yml

+13-17
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,22 @@ jobs:
2727
fail-fast: false
2828
matrix:
2929
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
30-
python-version: ['3.8', '3.9', '3.10', '3.11']
30+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
3131

3232
steps:
33-
- uses: actions/checkout@v3
34-
- uses: mamba-org/provision-with-micromamba@main
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-python@v4
3535
with:
36-
environment-file: false
37-
environment-name: gha-testing
38-
channels: conda-forge,nodefaults
39-
extra-specs: |
40-
python=${{ matrix.python-version }}
41-
mamba
42-
tox-conda
43-
cache-downloads: true
44-
45-
- name: Run end-to-end tests.
36+
python-version: ${{ matrix.python-version }}
37+
cache: pip
38+
allow-prereleases: true
39+
- run: pip install tox
40+
41+
- name: Run tests.
4642
shell: bash -l {0}
47-
run: tox -e pytest -- tests -m end_to_end --cov=./ --cov-report=xml -n auto
43+
run: tox -e test -- --cov=./ --cov-report=xml
4844

49-
- name: Upload coverage reports of end-to-end tests.
50-
if: runner.os == 'Linux' && matrix.python-version == '3.9'
45+
- name: Upload coverage reports of tests.
46+
if: runner.os == 'Linux' && matrix.python-version == '3.10'
5147
shell: bash -l {0}
52-
run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c
48+
run: bash <(curl -s https://codecov.io/bash)

.pre-commit-config.yaml

+14-38
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exclude: |
55
66
repos:
77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v4.4.0
8+
rev: v4.5.0
99
hooks:
1010
- id: check-added-large-files
1111
args: ['--maxkb=25']
@@ -38,46 +38,26 @@ repos:
3838
rev: v3.9.0
3939
hooks:
4040
- id: reorder-python-imports
41-
- repo: https://github.com/asottile/setup-cfg-fmt
42-
rev: v2.2.0
41+
- repo: https://github.com/aio-libs/sort-all
42+
rev: v1.2.0
4343
hooks:
44-
- id: setup-cfg-fmt
45-
exclude: |
46-
(?x)^(
47-
{{cookiecutter.project_slug}}/setup.cfg
48-
)$
49-
- repo: https://github.com/psf/black
50-
rev: 23.1.0
51-
hooks:
52-
- id: black
53-
- repo: https://github.com/charliermarsh/ruff-pre-commit
54-
rev: v0.0.241
44+
- id: sort-all
45+
- repo: https://github.com/astral-sh/ruff-pre-commit
46+
rev: v0.1.6
5547
hooks:
5648
- id: ruff
57-
args: [hooks, tests]
49+
args: [--config, pyproject.toml, hooks, tests]
5850
pass_filenames: false
51+
- id: ruff-format
52+
args: [--config, pyproject.toml]
5953
- repo: https://github.com/dosisod/refurb
60-
rev: v1.10.0
54+
rev: v1.24.0
6155
hooks:
6256
- id: refurb
6357
args: [--ignore, FURB126]
6458
exclude: ({{cookiecutter.project_slug}})
65-
- repo: https://github.com/econchick/interrogate
66-
rev: 1.5.0
67-
hooks:
68-
- id: interrogate
69-
args: [
70-
-v,
71-
--fail-under=40,
72-
--config,
73-
pyproject.toml,
74-
"{{cookiecutter.project_slug}}",
75-
--exclude,
76-
"{{cookiecutter.project_slug}}/tests/test_import.py"
77-
]
78-
pass_filenames: false
7959
- repo: https://github.com/executablebooks/mdformat
80-
rev: 0.7.16
60+
rev: 0.7.17
8161
hooks:
8262
- id: mdformat
8363
additional_dependencies: [
@@ -91,7 +71,7 @@ repos:
9171
{{cookiecutter.project_slug}}/README.md
9272
)$
9373
- repo: https://github.com/executablebooks/mdformat
94-
rev: 0.7.16
74+
rev: 0.7.17
9575
hooks:
9676
- id: mdformat
9777
additional_dependencies: [
@@ -106,18 +86,14 @@ repos:
10686
# path/to/file.py
10787
# )$
10888
- repo: https://github.com/codespell-project/codespell
109-
rev: v2.2.2
89+
rev: v2.2.6
11090
hooks:
11191
- id: codespell
11292
additional_dependencies: [tomli]
11393
- repo: https://github.com/pre-commit/mirrors-mypy
114-
rev: 'v0.991'
94+
rev: 'v1.7.0'
11595
hooks:
11696
- id: mypy
117-
args: [
118-
--no-strict-optional,
119-
--ignore-missing-imports,
120-
]
12197
pass_filenames: false
12298
- repo: meta
12399
hooks:

.readthedocs.yaml

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
version: 2
22

33
build:
4-
image: latest
4+
os: ubuntu-22.04
5+
tools:
6+
python: "3.10"
57

6-
python:
7-
version: 3.8
8+
sphinx:
9+
configuration: docs/source/conf.py
10+
fail_on_warning: true
811

9-
conda:
10-
environment: docs/docs_environment.yml
12+
python:
13+
install:
14+
- method: pip
15+
path: .
16+
extra_requirements:
17+
- docs

docs/docs_environment.yml

-23
This file was deleted.

docs/source/api.md

-12
This file was deleted.

docs/source/changes.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
This is a record of all past cookiecutter-pytask-project releases and what went into
44
them in reverse chronological order.
55

6+
## 1.6.0 - 2023-11-23
7+
8+
- {pull}`35` modernizes the template.
9+
610
## 1.5.0 - 2023-02-04
711

812
- {pull}`33` fixes some small things. (Thanks to @hmgaudecker!)

docs/source/conf.py

+5-17
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535
"sphinxext.opengraph",
3636
"sphinx.ext.viewcode",
3737
"sphinx_copybutton",
38-
"sphinx_panels",
39-
"autoapi.extension",
4038
"myst_parser",
39+
"sphinx_design",
4140
]
4241

4342
# Add any paths that contain templates here, relative to this directory.
@@ -48,23 +47,17 @@
4847
# html_extra_path.
4948
exclude_patterns = ["build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
5049

51-
# Configuration for autoapi to generate and API page.
52-
autoapi_type = "python"
53-
autoapi_dirs = ["../../hooks"]
54-
autoapi_keep_files = False
55-
autoapi_add_toctree_entry = False
56-
5750
# Remove prefixed $ for bash, >>> for Python prompts, and In [1]: for IPython prompts.
5851
copybutton_prompt_text = r"\$ |>>> |In \[\d\]: "
5952
copybutton_prompt_is_regexp = True
6053

6154
# Use these roles to create links to github users and pull requests.
6255
_repo = "https://github.com/pytask-dev/cookiecutter-pytask-project"
6356
extlinks = {
64-
"pypi": ("https://pypi.org/project/%s/", ""),
65-
"issue": (f"{_repo}/issues/%s", "issue #"),
66-
"pull": (f"{_repo}/pull/%s", "pull request #"),
67-
"user": ("https://github.com/%s", "@"),
57+
"pypi": ("https://pypi.org/project/%s/", "%s"),
58+
"issue": (f"{_repo}/issues/%s", "issue #%s"),
59+
"pull": (f"{_repo}/pull/%s", "pull request #%s"),
60+
"user": ("https://github.com/%s", "@%s"),
6861
}
6962

7063
# Link objects to other documentations.
@@ -85,8 +78,3 @@
8578

8679
pygments_style = "sphinx"
8780
pygments_dark_style = "monokai"
88-
89-
# Add any paths that contain custom static files (such as style sheets) here, relative
90-
# to this directory. They are copied after the builtin static files, so a file named
91-
# "default.css" will overwrite the builtin "default.css".
92-
html_static_path = ["_static"]

docs/source/index.md

-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,4 @@ maxdepth: 1
4747
---
4848
faq
4949
changes
50-
api
5150
```

environment.yml

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ dependencies:
3030
- myst-parser
3131
- nbsphinx
3232
- sphinx
33-
- sphinx-autoapi
3433
- sphinx-copybutton
3534
- sphinx-panels
3635

hooks/post_gen_project.py

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""This module contains hooks which are executed after the template is rendered."""
1+
"""Contains hooks which are executed after the template is rendered."""
22
from __future__ import annotations
33

44
import shutil
@@ -39,7 +39,9 @@ def main() -> None:
3939
remove_file(project_path, ".readthedocs.yaml")
4040

4141
subprocess.run(
42-
("git", "init", "--initial-branch", "main"), check=True, capture_output=True
42+
("git", "init", "--initial-branch", "main"),
43+
check=True,
44+
capture_output=True,
4345
)
4446

4547
if "{{ cookiecutter.make_initial_commit }}" == "yes":
@@ -78,10 +80,35 @@ def main() -> None:
7880
check=True,
7981
capture_output=True,
8082
)
83+
# Install pre-commit hooks and run them.
84+
subprocess.run( # noqa: PLW1510
85+
(
86+
conda_exe,
87+
"run",
88+
"-n",
89+
"{{ cookiecutter.conda_environment_name }}",
90+
"pre-commit",
91+
"install",
92+
),
93+
capture_output=True,
94+
)
95+
subprocess.run( # noqa: PLW1510
96+
(
97+
conda_exe,
98+
"run",
99+
"-n",
100+
"{{ cookiecutter.conda_environment_name }}",
101+
"pre-commit",
102+
"run",
103+
"--all-files",
104+
),
105+
capture_output=True,
106+
)
81107
else:
82108
warnings.warn(
83109
"conda environment could not be created since no conda or mamba "
84-
"executable was found."
110+
"executable was found.",
111+
stacklevel=1,
85112
)
86113

87114

hooks/pre_gen_project.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""This module contains hooks which are executed before the template is rendered."""
1+
"""Contains hooks which are executed before the template is rendered."""
22
import re
33

44
MODULE_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]*$"
@@ -36,15 +36,16 @@ def main() -> None:
3636

3737
if not re.match(ENVIRON_REGEX, environment_name):
3838
raise ValueError(
39-
EXCEPTION_MSG_ENVIRON_NAME.format(environment_name=environment_name)
39+
EXCEPTION_MSG_ENVIRON_NAME.format(environment_name=environment_name),
4040
)
4141

4242
python_version = "{{ cookiecutter.python_version }}"
4343

4444
if not re.match(PYTHONVERSION_REGEX, python_version):
4545
raise ValueError(
4646
EXCEPTION_MSG_PYTHONVERSION.format(
47-
min_python_version=PYTHONVERSION_MIN, python_version=python_version
47+
min_python_version=PYTHONVERSION_MIN,
48+
python_version=python_version,
4849
),
4950
)
5051

0 commit comments

Comments
 (0)