Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 2d0d6e6

Browse files
authored
Merge pull request #4 from ilbumi/dev
Dev 0.1.0 merge
2 parents ca0977b + b742f48 commit 2d0d6e6

13 files changed

Lines changed: 241 additions & 22 deletions
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ jobs:
4444
git config --global init.defaultBranch main
4545
4646
- name: Install dependencies
47-
run: python -m pip install -U copier
48-
49-
- name: Setup tests (Unix)
50-
run: bash tests/setup.sh
51-
if: runner.os != 'Windows'
47+
run: pip install copier==${{ matrix.copier-version }} copier-templates-extensions
5248

5349
- name: Run tests
5450
run: bash tests/test_generate.sh
55-
working-directory: ${{ github.workspace }}/tests/tmp

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ The template is heavily inspired by [Pawamoy's Copier PDM](https://github.com/pa
1111

1212
### Existing features
1313

14+
- Python 3.9 or above
15+
- Pre-configured tools for code formatting, quality analysis and testing:
16+
- [black](https://github.com/psf/black),
17+
- [ruff](https://github.com/charliermarsh/ruff),
18+
- [mypy](https://github.com/python/mypy),
19+
- Tests run with [pytest](https://github.com/pytest-dev/pytest) and plugins
20+
- [Nox](https://github.com/wntrblm/nox) as task runner
21+
- All licenses from [choosealicense.com](https://choosealicense.com/appendix/)
22+
1423
### Planned Features
1524

1625
- VSCode Dev Containers as development environments
@@ -19,32 +28,27 @@ The template is heavily inspired by [Pawamoy's Copier PDM](https://github.com/pa
1928
([Material theme](https://github.com/squidfunk/mkdocs-material)
2029
and "autodoc" [mkdocstrings plugin](https://github.com/mkdocstrings/mkdocstrings))
2130
- Pre-configured tools for code formatting, quality analysis and testing:
22-
- [black](https://github.com/psf/black),
2331
- [blacken-docs](https://github.com/adamchainz/blacken-docs),
2432
- [ssort](https://github.com/bwhmather/ssort),
25-
- [ruff](https://github.com/charliermarsh/ruff),
26-
- [mypy](https://github.com/python/mypy),
2733
- [safety](https://github.com/pyupio/safety)
28-
- Tests run with [pytest](https://github.com/pytest-dev/pytest) and plugins, with [coverage](https://github.com/nedbat/coveragepy) support
29-
- [Nox](https://github.com/wntrblm/nox) as task runner
30-
- Python 3.9 or above
34+
- [coverage](https://github.com/nedbat/coveragepy) support for tests
3135
- Auto-generated `CHANGELOG.md` from git commits
32-
- All licenses from [choosealicense.com](https://choosealicense.com/appendix/)
33-
- Makefile for convenience
3436
- Support for GitHub workflows and GitLab CI/CD
3537

3638
## Quick setup and usage
3739

3840
### Requirements
3941

42+
You need `copier` installed in order to use this template.
43+
4044
### Starting a project
4145

4246
```bash
43-
copier copy "https://github.com/ilbumi/copier-python-vscode.git" /path/to/your/new/project
47+
copier copy --trust "https://github.com/ilbumi/copier-python-vscode.git" /path/to/your/new/project
4448
```
4549

4650
Or even shorter:
4751

4852
```bash
49-
copier copy "gh:ilbumi/copier-python-vscode" /path/to/your/new/project
53+
copier copy --trust "gh:ilbumi/copier-python-vscode" /path/to/your/new/project
5054
```

project/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ pdm.toml
1515
.pdm-python
1616
__pypackages__/
1717
.venv/
18-
.cache/
18+
.cache/
19+
.nox/

project/config/bandit.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.bandit]
2+
exclude_dirs = ["tests"]
3+
skips = ["B101"]

project/config/black.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.black]
2+
line-length = 120
3+
exclude = "tests/fixtures"

project/config/mypy.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[mypy]
2+
ignore_missing_imports = true
3+
exclude = tests/fixtures/
4+
warn_unused_ignores = true
5+
show_error_codes = true

project/config/ruff.toml.jinja

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
target-version = "py38"
2+
line-length = 132
3+
exclude = [
4+
"fixtures",
5+
"site",
6+
]
7+
select = [
8+
"A",
9+
"ANN",
10+
"ARG",
11+
"B",
12+
"BLE",
13+
"C",
14+
"C4",
15+
"COM",
16+
"D",
17+
"DTZ",
18+
"E",
19+
"ERA",
20+
"EXE",
21+
"F",
22+
"FBT",
23+
"G",
24+
"I",
25+
"ICN",
26+
"INP",
27+
"ISC",
28+
"N",
29+
"PGH",
30+
"PIE",
31+
"PL",
32+
"PLC",
33+
"PLE",
34+
"PLR",
35+
"PLW",
36+
"PT",
37+
"PYI",
38+
"Q",
39+
"RUF",
40+
"RSE",
41+
"RET",
42+
"S",
43+
"SIM",
44+
"SLF",
45+
"T",
46+
"T10",
47+
"T20",
48+
"TCH",
49+
"TID",
50+
"TRY",
51+
"UP",
52+
"W",
53+
"YTT",
54+
]
55+
ignore = [
56+
"A001", # Variable is shadowing a Python builtin
57+
"ANN101", # Missing type annotation for self
58+
"ANN102", # Missing type annotation for cls
59+
"ANN204", # Missing return type annotation for special method __str__
60+
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
61+
"ARG005", # Unused lambda argument
62+
"D105", # Missing docstring in magic method
63+
"D417", # Missing argument description in the docstring
64+
"E501", # Line too long
65+
"ERA001", # Commented out code
66+
"G004", # Logging statement uses f-string
67+
"PLR0911", # Too many return statements
68+
"PLR0915", # Too many statements
69+
"SLF001", # Private member accessed
70+
"TRY003", # Avoid specifying long messages outside the exception class
71+
]
72+
73+
[per-file-ignores]
74+
"src/*/cli.py" = [
75+
"T201", # Print statement
76+
]
77+
"scripts/*.py" = [
78+
"INP001", # File is part of an implicit namespace package
79+
"T201", # Print statement
80+
]
81+
"tests/*.py" = [
82+
"ARG005", # Unused lambda argument
83+
"FBT001", # Boolean positional arg in function definition
84+
"PLR2004", # Magic value used in comparison
85+
"S101", # Use of assert detected
86+
]
87+
88+
[flake8-quotes]
89+
docstring-quotes = "double"
90+
91+
[flake8-tidy-imports]
92+
ban-relative-imports = "all"
93+
94+
[isort]
95+
known-first-party = ["{{ python_package_import_name }}"]
96+
97+
[pydocstyle]
98+
convention = "google"

project/noxfile.py.jinja

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,71 @@
1+
"""File with common jobs definitions. Run them with 'pdm run nox -e [job_name]'."""
12
import os
3+
import tempfile
24

35
import nox
6+
from nox.sessions import Session
47

58
os.environ.update(PDM_IGNORE_SAVED_PYTHON="1", PDM_USE_VENV="1")
69

10+
PYSRC = ["src/", "noxfile.py", "tests/"]
711

8-
@nox.session(python=("3.9", "3.10", "3.11"))
9-
def test(session):
10-
session.run_always("pdm", "install", "-Gtest", external=True)
11-
session.run("pytest", "tests/")
12+
13+
@nox.session
14+
def test(session: Session) -> None:
15+
"""Run tests.
16+
17+
Args:
18+
session (Session): nox session object
19+
"""
20+
session.run_always("pdm", "install", "-G", "ci-tests", external=True)
21+
session.run("pytest", "--cov", "tests/")
22+
23+
24+
@nox.session
25+
def format(session: Session) -> None:
26+
"""Run autoformatters.
27+
28+
Args:
29+
session (Session): nox session object
30+
"""
31+
session.run_always("pdm", "install", "-G", "ci-quality", external=True)
32+
session.run("ruff", "check", "--config", "config/ruff.toml", "--fix", *PYSRC)
33+
session.run("black", "--config", "config/black.toml", *PYSRC)
34+
35+
36+
@nox.session
37+
def lint(session: Session) -> None:
38+
"""Run ruff checks.
39+
40+
Args:
41+
session (Session): nox session object
42+
"""
43+
session.run_always("pdm", "install", "-G", "ci-quality", external=True)
44+
session.run("ruff", "check", "--config", "config/ruff.toml", *PYSRC)
45+
46+
47+
@nox.session
48+
def check_types(session: Session) -> None:
49+
"""Run type checking.
50+
51+
Args:
52+
session (Session): nox session object
53+
"""
54+
session.run_always("pdm", "install", "-G", "ci-quality", external=True)
55+
session.run("mypy", "--config-file", "config/mypy.ini", *PYSRC)
56+
57+
58+
@nox.session
59+
def check_safety(session: Session) -> None:
60+
"""Run safety checks.
61+
62+
Args:
63+
session (Session): nox session object
64+
"""
65+
session.run_always("pdm", "install", "-G", "ci-quality", external=True)
66+
session.run("bandit", "--configfile", "config/bandit.toml", *PYSRC)
67+
with tempfile.NamedTemporaryFile() as requirements:
68+
session.run(
69+
"pdm", "export", "-f", "requirements", "-o", requirements.name, "--without-hashes", external=True
70+
)
71+
session.run("safety", "check", f"--file={requirements.name}", "--full-report")

project/tests/__init__.py.jinja

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""Tests suite for `{{ python_package_import_name }}`."""
2+
3+
from pathlib import Path
4+
5+
TESTS_DIR = Path(__file__).parent
6+
TMP_DIR = TESTS_DIR / "tmp"
7+
FIXTURES_DIR = TESTS_DIR / "fixtures"

0 commit comments

Comments
 (0)