Skip to content

Commit 58dbe00

Browse files
committed
update
1 parent 821d306 commit 58dbe00

9 files changed

Lines changed: 36 additions & 63 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@ on:
88
jobs:
99
test:
1010
runs-on: ubuntu-latest
11-
if: "!contains(github.event.head_commit.message, 'ci skip')"
1211
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-python@v2
15-
- uses: actions/cache@v2
16-
with:
17-
path: ~/.cache/pip
18-
key: ${{ runner.os }}-pip
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v4
1914
- name: Install dependencies
20-
run: pip install poetry~=1.1 'copier>=6.0.0a6'
15+
run: |
16+
pipx install copier
17+
pipx install poetry
2118
- name: Run test
2219
run: |
2320
git config --global user.name "GitHub Action"
2421
git config --global user.email "action@github.com"
25-
copier -f -d docker=True -d docs=True . build/ && cd build/
22+
copier copy --trust -f -d docker=True -d docs=True . build/ && cd build/
2623
poetry run task lint
2724
- name: Push rendered project
2825
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ A [Copier](https://github.com/copier-org/copier) template for a Python package b
66

77
## Usage
88

9-
> **Requires**: copier>=6.0.0a7
10-
119
```sh
12-
copier gh:branchvincent/python-template <dest>
10+
pipx run copier copy --trust gh:branchvincent/python-template <dest>
1311
```
1412

1513
## Features
1614

1715
- Package manager: [Poetry](https://python-poetry.org/)
18-
- Formatting: [Black](https://black.readthedocs.io/en/stable/) and [isort](https://isort.readthedocs.io/en/latest/)
16+
- Formatting: [Ruff](https://docs.astral.sh/ruff/formatter/)
1917
- Testing: [pytest](https://docs.pytest.org/en/latest/)
20-
- Linting: [flake8](https://flake8.pycqa.org/) and [pre-commit](https://pre-commit.com/)
18+
- Linting: [Ruff](https://docs.astral.sh/ruff/linter/) and [pre-commit](https://pre-commit.com/)
2119
- Typing: [mypy](https://mypy.readthedocs.io/en/stable/)
2220
- Task runner: [taskipy](https://github.com/illBeRoy/taskipy)
2321
- CI/CD: [Github Actions](https://docs.github.com/en/actions)

copier.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,5 @@ _exclude:
3838
- /macros
3939
_skip_if_exists:
4040
- pyproject.toml
41-
_min_copier_version: 6.0.0a7
4241
_tasks:
4342
- bash postgenerate.sh

src/.github/workflows/ci.yaml.jinja

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,14 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
if: "!contains(github.event.head_commit.message, 'ci skip')"
1312
steps:
14-
- uses: actions/checkout@v2
15-
- uses: actions/setup-python@v2
16-
with:
17-
python-version: 3.9
13+
- uses: actions/checkout@v4
1814
- name: Set up Poetry
19-
run: |
20-
pip install poetry
21-
poetry config virtualenvs.in-project true
22-
- name: Set up cache
23-
uses: actions/cache@v2
15+
run: pipx install poetry
16+
- uses: actions/setup-python@v4
2417
with:
25-
path: .venv
26-
key: {% raw %}${{ runner.os }}-venv-py3.9-${{ hashFiles('**/poetry.lock') }}{% endraw %}
18+
python-version: 3.12
19+
cache: poetry
2720
- name: Install package
2821
run: poetry install
2922
- name: Run linters
@@ -36,7 +29,7 @@ jobs:
3629
runs-on: ubuntu-latest
3730
if: github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'cd skip')
3831
steps:
39-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v4
4033
- name: Bump version
4134
uses: TriPSs/conventional-changelog-action@v3
4235
id: version
@@ -58,7 +51,7 @@ jobs:
5851
{% if not private -%}
5952
- name: Publish to PyPI
6053
if: steps.version.outputs.skipped == 'false'
61-
run: pip install poetry && poetry publish --build
54+
run: pipx run poetry publish --build
6255
env:
6356
POETRY_PYPI_TOKEN_PYPI: {% raw %}${{ secrets.PYPI_TOKEN }}{% endraw %}
6457
{% endif -%}

src/.pre-commit-config.yaml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
repos:
2-
- repo: https://github.com/asottile/pyupgrade
3-
rev: v2.20.1
4-
hooks:
5-
- id: pyupgrade
62
- repo: local
73
hooks:
8-
- id: isort
9-
name: isort
10-
entry: poetry run isort
11-
language: system
12-
types: [python]
13-
- id: black
14-
name: black
15-
entry: poetry run black
4+
- id: ruff-format
5+
name: ruff-format
6+
entry: poetry run ruff format
7+
require_serial: true
168
language: system
179
types: [python]
18-
- id: flake8
19-
name: flake8
20-
entry: poetry run pflake8
10+
- id: ruff-check
11+
name: ruff-check
12+
entry: poetry run ruff check
13+
require_serial: true
2114
language: system
2215
types: [python]
2316
- id: mypy

src/CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ poetry run task --list
2626

2727
To ensure code quality, we use the following tools:
2828

29-
- Formatting: [black](https://black.readthedocs.io/en/stable/) and [isort](https://isort.readthedocs.io/en/latest/)
30-
- Linting: [flake8](http://flake8.pycqa.org/en/latest/)
29+
- Formatting and linting: [ruff](https://docs.astral.sh/ruff/)
3130
- Type checking: [mypy](https://mypy.readthedocs.io/en/stable/)
3231

3332
To run these:

src/README.md.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% if not private -%}
55
[![pypi version](https://img.shields.io/pypi/v/{{project_name}}.svg)](https://pypi.org/project/{{project_name}}/)
66
{% endif -%}
7-
[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
7+
[![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
88
[![checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
99

1010
{{project_description}}

src/pyproject.toml.jinja

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@ classifiers = ["Private :: Do Not Upload"]
1111
{%- endif %}
1212

1313
[tool.poetry.dependencies]
14-
python = "^3.9"
14+
python = "^3.10"
1515

16-
[tool.poetry.dev-dependencies]
17-
black = "*"
18-
flake8 = "*"
19-
isort = "*"
16+
[tool.poetry.group.dev.dependencies]
2017
{% if docs -%}
2118
mkdocs = "*"
2219
mkdocs-material = "*"
2320
{% endif -%}
2421
mypy = "*"
2522
pre-commit = "*"
26-
pyproject-flake8 = "*"
2723
pytest = "*"
24+
ruff = "*"
2825
taskipy = "*"
2926

3027
[tool.taskipy.tasks]
@@ -35,12 +32,9 @@ docs = { cmd = "mkdocs serve -f docs/mkdocs.yaml", help = "Serve documentation"}
3532
lint = { cmd = "pre-commit run --all-files", help = "Run linters and formatters" }
3633
test = { cmd = "pytest", help = "Run tests" }
3734

38-
[tool.flake8]
39-
max-line-length = 88
40-
extend-ignore = "E203"
41-
42-
[tool.isort]
43-
profile = "black"
35+
[tool.ruff]
36+
fix = true
37+
select = ["B", "E", "F", "I", "SIM", "UP"]
4438

4539
[tool.mypy]
4640
strict = true

src/{% if docker %}Dockerfile{% endif %}.jinja

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
FROM python:3.9-alpine AS base
1+
FROM python:3.12-alpine AS base
22
WORKDIR /app
33

44
### Builder ###
55
FROM base AS builder
66

77
# Install poetry
8-
RUN pip install --no-cache-dir poetry~=1.1 \
8+
RUN pip install --no-cache-dir poetry~=1.6 \
99
&& poetry config virtualenvs.in-project true
1010

1111
# Install deps
1212
COPY pyproject.toml poetry.lock ./
13-
RUN poetry install --no-root --no-dev
13+
RUN poetry install --no-root --only=main
1414

1515
# Add source
1616
COPY . .
17-
RUN poetry install --no-dev
17+
RUN poetry install --only=main
1818

1919
### Runner ###
2020
FROM base AS runner

0 commit comments

Comments
 (0)