Skip to content

Commit 2b8ca3e

Browse files
Merge pull request #170 from dalito/issue169-cleaner-linter-defaults
Cleaner linter defaults and minor template polish
2 parents 396e6f6 + 4d170e8 commit 2b8ca3e

12 files changed

Lines changed: 51 additions & 34 deletions

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ The commands are written to be run at the root of your project.
209209
Be sure to enter the same values when answering the copier questions.
210210

211211
* Carefully review the changes that copier made to your project.
212+
* Pay particular attention to linter and formatter configurations — the template ships
213+
rules in `.pre-commit-config.yaml`, `.yamllint.yaml`, `.editorconfig`, and the
214+
`[tool.ruff]` / `[tool.codespell]` / `[tool.typos]` sections of `pyproject.toml`.
215+
You'll likely want to merge the template's settings with your existing setup rather
216+
than accept either side wholesale.
212217
* If you used a cruft/cookiecutter template before, you may delete the cruft file `.cruft.json`.
213218
* If you are happy, commit all changes to the `migrate-to-copier` branch.
214219
* To finalise the migration, merge the `migrate-to-copier` branch to your main branch.

template/.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on: # yamllint disable-line rule:truthy
99
pull_request:
1010

1111
env:
12-
FORCE_COLOR: "1" # Make tools pretty.
12+
FORCE_COLOR: "1" # Make tools pretty.
1313

1414
permissions: {}
1515

template/.github/workflows/{% if gh_action_docs_preview %}test_pages_build.yaml{% endif %}.jinja

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,12 @@ jobs:
4141
- name: Set up Python
4242
uses: actions/setup-python@v6.0.0
4343
with:
44-
{% raw %}
45-
python-version: ${{ matrix.pyversion }}
46-
{% endraw %}
44+
{% raw %}python-version: ${{ matrix.pyversion }}{% endraw %}
4745
# https://github.com/astral-sh/setup-uv
4846
- name: Install uv
4947
uses: astral-sh/setup-uv@v7.1.2
5048
with:
51-
{% raw %}
52-
python-version: ${{ matrix.pyversion }}
53-
{% endraw %}
49+
{% raw %}python-version: ${{ matrix.pyversion }}{% endraw %}
5450
enable-cache: true
5551
cache-dependency-glob: "uv.lock"
5652

template/.github/workflows/{% if gh_action_pypi %}pypi-publish.yaml{% endif %}.jinja

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ name: Publish Python Package
1111
on: # yamllint disable-line rule:truthy
1212
push:
1313
tags:
14-
# GitHub glob matching is limited [1]. So we can't define a pattern matching
14+
# GitHub glob matching is limited. So we can't define a pattern matching
1515
# pep 440 version definition [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
1616
- 'v[0-9]+.[0-9]+.[0-9]+.?*'
1717
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]'
@@ -40,18 +40,14 @@ jobs:
4040
- name: Install uv
4141
uses: astral-sh/setup-uv@v7.1.2
4242
with:
43-
{% raw %}
44-
python-version: ${{ matrix.pyversion }}
45-
{% endraw %}
43+
{% raw %}python-version: ${{ matrix.pyversion }}{% endraw %}
4644
enable-cache: true
4745

4846
# https://github.com/actions/setup-python
4947
- name: Set up Python
5048
uses: actions/setup-python@v6.0.0
5149
with:
52-
{% raw %}
53-
python-version: ${{ matrix.pyversion }}
54-
{% endraw %}
50+
{% raw %}python-version: ${{ matrix.pyversion }}{% endraw %}
5551

5652
- name: Install just
5753
run: |
@@ -97,5 +93,3 @@ jobs:
9793
uses: pypa/gh-action-pypi-publish@v1.13.0
9894
with:
9995
verbose: true
100-
101-
# [1] https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

template/.pre-commit-config.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ repos:
99
# mkdocs.yml uses !!python/name tags unsupported by the safe YAML loader
1010
exclude: ^mkdocs\.yml$
1111
- id: end-of-file-fixer
12+
exclude: ^\.copier-answers\.yml$
1213
- id: trailing-whitespace
1314
args: [--markdown-linebreak-ext=md]
1415

@@ -17,22 +18,24 @@ repos:
1718
hooks:
1819
- id: yamllint
1920
args: [-c=.yamllint.yaml]
21+
exclude: ^\.copier-answers\.yml$
22+
verbose: true # Show warnings but don't fail the commit.
2023

2124
- repo: https://github.com/codespell-project/codespell
22-
rev: v2.4.1
25+
rev: v2.4.2
2326
hooks:
2427
- id: codespell
2528
additional_dependencies:
2629
- tomli
2730

2831
- repo: https://github.com/crate-ci/typos
29-
rev: v1.44.0
32+
rev: v1.46.3
3033
hooks:
3134
- id: typos
3235

3336
- repo: https://github.com/astral-sh/ruff-pre-commit
3437
# Ruff version.
35-
rev: v0.15.4
38+
rev: v0.15.14
3639
hooks:
3740
# Run the linter.
3841
- id: ruff
@@ -42,6 +45,6 @@ repos:
4245

4346
- repo: https://github.com/astral-sh/uv-pre-commit
4447
# uv version.
45-
rev: 0.9.28
48+
rev: 0.11.16
4649
hooks:
4750
- id: uv-lock

template/.yamllint.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
extends: default
44

5+
# Specify files to ignore.
6+
ignore:
7+
# Ignore autogenerated file that does not conform to yamllint rules.
8+
- .copier-answers.yml
9+
# Ignore schema files that may not conform due to imports.
10+
- docs/schema/*.yaml
11+
512
rules:
613
document-start: disable # Don't check if document has a start marker (---).
714
line-length:
8-
max: 80
15+
max: 88
916
level: warning
1017
allow-non-breakable-words: true
1118
allow-non-breakable-inline-mappings: true

template/justfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# ============ Hint for for Windows Users ============
1+
# ============ Shell configuration for Windows ============
22

3-
# On Windows the "sh" shell that comes with Git for Windows should be used.
4-
# If it is not on path, provide the path to the executable in the following line.
5-
#set windows-shell := ["C:/Program Files/Git/usr/bin/sh", "-cu"]
3+
# On Windows the "bash" shell from Git for Windows is used.
4+
# If Git is installed in a non-standard location, edit the path below.
5+
set windows-shell := ["C:/Program Files/Git/bin/bash", "-cu"]
66

77
# ============ Variables used in recipes ============
88

template/mkdocs.yml.jinja

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ plugins:
2828
execute: false
2929
- mermaid2:
3030
version: 11.4.1
31+
# https://pypi.org/project/mkdocs-pymdownx-material-extras
3132
- mkdocs_pymdownx_material_extras:
32-
# https://pypi.org/project/mkdocs-pymdownx-material-extras
3333

3434
markdown_extensions:
3535
- pymdownx.superfences:
@@ -56,11 +56,6 @@ markdown_extensions:
5656
# write markdown inside of HTML
5757
- md_in_html
5858

59-
# TODO rebuild docs on schema change (https://github.com/linkml/linkml-project-copier/issues/39)
60-
# - gen-files:
61-
# scripts:
62-
# - gen_pages.py # or any other name or path
63-
6459
watch:
6560
- src/{{ project_slug }}/schema
6661

template/pyproject.toml.jinja

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ fallback-version = "0.0.0"
4444
[tool.pytest.ini_options]
4545
testpaths = ["tests"]
4646

47+
# https://docs.astral.sh/ruff/configuration/
48+
[tool.ruff]
49+
exclude = [
50+
"src/{{project_slug}}/_version.py",
51+
]
52+
# Set oldest supported Python version
53+
target-version = "py310"
54+
4755
# Ref.: https://github.com/codespell-project/codespell
4856
[tool.codespell]
4957
skip = [
@@ -62,6 +70,7 @@ quiet-level = 3
6270
# Ref.: https://github.com/crate-ci/typos (spell checker)
6371
[tool.typos.default.extend-words]
6472
linke = "linke"
73+
6574
[tool.typos.files]
6675
extend-exclude = [
6776
"LICENSE",

template/src/{{project_slug}}/__init__.py.jinja

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""{{project_name}}
2+
3+
{{project_description}}
4+
"""
5+
16
try:
27
from {{project_slug}}._version import __version__, __version_tuple__
38
except ImportError: # pragma: no cover

0 commit comments

Comments
 (0)