Skip to content

Modernize template. #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,22 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- uses: mamba-org/provision-with-micromamba@main
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
environment-file: false
environment-name: gha-testing
channels: conda-forge,nodefaults
extra-specs: |
python=${{ matrix.python-version }}
mamba
tox-conda
cache-downloads: true

- name: Run end-to-end tests.
python-version: ${{ matrix.python-version }}
cache: pip
allow-prereleases: true
- run: pip install tox

- name: Run tests.
shell: bash -l {0}
run: tox -e pytest -- tests -m end_to_end --cov=./ --cov-report=xml -n auto
run: tox -e test -- --cov=./ --cov-report=xml

- name: Upload coverage reports of end-to-end tests.
if: runner.os == 'Linux' && matrix.python-version == '3.9'
- name: Upload coverage reports of tests.
if: runner.os == 'Linux' && matrix.python-version == '3.10'
shell: bash -l {0}
run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c
run: bash <(curl -s https://codecov.io/bash)
52 changes: 14 additions & 38 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exclude: |

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
args: ['--maxkb=25']
Expand Down Expand Up @@ -38,46 +38,26 @@ repos:
rev: v3.9.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
- repo: https://github.com/aio-libs/sort-all
rev: v1.2.0
hooks:
- id: setup-cfg-fmt
exclude: |
(?x)^(
{{cookiecutter.project_slug}}/setup.cfg
)$
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.241
- id: sort-all
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: [hooks, tests]
args: [--config, pyproject.toml, hooks, tests]
pass_filenames: false
- id: ruff-format
args: [--config, pyproject.toml]
- repo: https://github.com/dosisod/refurb
rev: v1.10.0
rev: v1.24.0
hooks:
- id: refurb
args: [--ignore, FURB126]
exclude: ({{cookiecutter.project_slug}})
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
- id: interrogate
args: [
-v,
--fail-under=40,
--config,
pyproject.toml,
"{{cookiecutter.project_slug}}",
--exclude,
"{{cookiecutter.project_slug}}/tests/test_import.py"
]
pass_filenames: false
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies: [
Expand All @@ -91,7 +71,7 @@ repos:
{{cookiecutter.project_slug}}/README.md
)$
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies: [
Expand All @@ -106,18 +86,14 @@ repos:
# path/to/file.py
# )$
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies: [tomli]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.991'
rev: 'v1.7.0'
hooks:
- id: mypy
args: [
--no-strict-optional,
--ignore-missing-imports,
]
pass_filenames: false
- repo: meta
hooks:
Expand Down
17 changes: 12 additions & 5 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
version: 2

build:
image: latest
os: ubuntu-22.04
tools:
python: "3.10"

python:
version: 3.8
sphinx:
configuration: docs/source/conf.py
fail_on_warning: true

conda:
environment: docs/docs_environment.yml
python:
install:
- method: pip
path: .
extra_requirements:
- docs
23 changes: 0 additions & 23 deletions docs/docs_environment.yml

This file was deleted.

12 changes: 0 additions & 12 deletions docs/source/api.md

This file was deleted.

4 changes: 4 additions & 0 deletions docs/source/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This is a record of all past cookiecutter-pytask-project releases and what went into
them in reverse chronological order.

## 1.6.0 - 2023-11-23

- {pull}`35` modernizes the template.

## 1.5.0 - 2023-02-04

- {pull}`33` fixes some small things. (Thanks to @hmgaudecker!)
Expand Down
22 changes: 5 additions & 17 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
"sphinxext.opengraph",
"sphinx.ext.viewcode",
"sphinx_copybutton",
"sphinx_panels",
"autoapi.extension",
"myst_parser",
"sphinx_design",
]

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

# Configuration for autoapi to generate and API page.
autoapi_type = "python"
autoapi_dirs = ["../../hooks"]
autoapi_keep_files = False
autoapi_add_toctree_entry = False

# Remove prefixed $ for bash, >>> for Python prompts, and In [1]: for IPython prompts.
copybutton_prompt_text = r"\$ |>>> |In \[\d\]: "
copybutton_prompt_is_regexp = True

# Use these roles to create links to github users and pull requests.
_repo = "https://github.com/pytask-dev/cookiecutter-pytask-project"
extlinks = {
"pypi": ("https://pypi.org/project/%s/", ""),
"issue": (f"{_repo}/issues/%s", "issue #"),
"pull": (f"{_repo}/pull/%s", "pull request #"),
"user": ("https://github.com/%s", "@"),
"pypi": ("https://pypi.org/project/%s/", "%s"),
"issue": (f"{_repo}/issues/%s", "issue #%s"),
"pull": (f"{_repo}/pull/%s", "pull request #%s"),
"user": ("https://github.com/%s", "@%s"),
}

# Link objects to other documentations.
Expand All @@ -85,8 +78,3 @@

pygments_style = "sphinx"
pygments_dark_style = "monokai"

# Add any paths that contain custom static files (such as style sheets) here, relative
# to this directory. They are copied after the builtin static files, so a file named
# "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
1 change: 0 additions & 1 deletion docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ maxdepth: 1
---
faq
changes
api
```
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies:
- myst-parser
- nbsphinx
- sphinx
- sphinx-autoapi
- sphinx-copybutton
- sphinx-panels

Expand Down
33 changes: 30 additions & 3 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module contains hooks which are executed after the template is rendered."""
"""Contains hooks which are executed after the template is rendered."""
from __future__ import annotations

import shutil
Expand Down Expand Up @@ -39,7 +39,9 @@ def main() -> None:
remove_file(project_path, ".readthedocs.yaml")

subprocess.run(
("git", "init", "--initial-branch", "main"), check=True, capture_output=True
("git", "init", "--initial-branch", "main"),
check=True,
capture_output=True,
)

if "{{ cookiecutter.make_initial_commit }}" == "yes":
Expand Down Expand Up @@ -78,10 +80,35 @@ def main() -> None:
check=True,
capture_output=True,
)
# Install pre-commit hooks and run them.
subprocess.run( # noqa: PLW1510
(
conda_exe,
"run",
"-n",
"{{ cookiecutter.conda_environment_name }}",
"pre-commit",
"install",
),
capture_output=True,
)
subprocess.run( # noqa: PLW1510
(
conda_exe,
"run",
"-n",
"{{ cookiecutter.conda_environment_name }}",
"pre-commit",
"run",
"--all-files",
),
capture_output=True,
)
else:
warnings.warn(
"conda environment could not be created since no conda or mamba "
"executable was found."
"executable was found.",
stacklevel=1,
)


Expand Down
7 changes: 4 additions & 3 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module contains hooks which are executed before the template is rendered."""
"""Contains hooks which are executed before the template is rendered."""
import re

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

if not re.match(ENVIRON_REGEX, environment_name):
raise ValueError(
EXCEPTION_MSG_ENVIRON_NAME.format(environment_name=environment_name)
EXCEPTION_MSG_ENVIRON_NAME.format(environment_name=environment_name),
)

python_version = "{{ cookiecutter.python_version }}"

if not re.match(PYTHONVERSION_REGEX, python_version):
raise ValueError(
EXCEPTION_MSG_PYTHONVERSION.format(
min_python_version=PYTHONVERSION_MIN, python_version=python_version
min_python_version=PYTHONVERSION_MIN,
python_version=python_version,
),
)

Expand Down
Loading