Skip to content

Commit d751408

Browse files
Switch to UV
1 parent e766526 commit d751408

12 files changed

Lines changed: 150 additions & 72 deletions

File tree

.dockerignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@ notebooks/
1111
data.dvc
1212
docker-compose.yml
1313
Makefile
14-
pyproject.toml
1514
README.md
16-
requirements-dev.txt
17-
requirements-test.txt
1815
.dvcignore
19-
.git
20-
.idea
16+
.git/
17+
.idea/
2118
.mypy_cache
2219
.pytest_cache
2320
.ruff_cache

.github/workflows/ci.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,22 @@ jobs:
1111
- name: Checkout repository code
1212
uses: actions/checkout@v4
1313

14-
- name: Set up Python 3.13
15-
uses: actions/setup-python@v5
16-
with:
17-
python-version: 3.13
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v6
1816

19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install poetry
23-
poetry install
17+
- name: Set up Python
18+
run: uv python install
19+
20+
- name: Install the project
21+
run: uv sync --all-groups
2422

25-
- name: Code quality checks
26-
uses: astral-sh/ruff-action@v3
27-
with:
28-
args: "format --check"
29-
version: "latest"
23+
- name: Run Ruff
24+
run: uv run ruff check --output-format=github .
3025

3126
- name: MyPy type checking
3227
run: |
33-
poetry run mypy --strict
28+
uv run mypy --strict
3429
3530
- name: Test with pytest
3631
run: |
37-
poetry run pytest
32+
uv run pytest

.gitignore

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
# Poetry
2-
poetry.lock
3-
41
# Other
52
.DS_Store
63
._.DS_Store
74
**/.DS_Store
85
**/._.DS_Store
9-
.idea/
106

117
# Byte-compiled / optimized / DLL files
128
__pycache__/
13-
*.py[cod]
9+
*.py[codz]
1410
*$py.class
1511

1612
# C extensions
@@ -56,7 +52,7 @@ htmlcov/
5652
nosetests.xml
5753
coverage.xml
5854
*.cover
59-
*.py,cover
55+
*.py.cover
6056
.hypothesis/
6157
.pytest_cache/
6258
cover/
@@ -102,22 +98,37 @@ ipython_config.py
10298
# However, in case of collaboration, if having platform-specific dependencies or dependencies
10399
# having no cross-platform support, pipenv may install dependencies that don't work, or not
104100
# install all needed dependencies.
105-
#Pipfile.lock
101+
# Pipfile.lock
102+
103+
# UV
104+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
uv.lock
106108

107109
# poetry
108110
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
109111
# This is especially recommended for binary packages to ensure reproducibility, and is more
110112
# commonly ignored for libraries.
111113
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
112-
#poetry.lock
114+
# poetry.lock
115+
# poetry.toml
113116

114117
# pdm
115118
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
116-
#pdm.lock
117-
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
118-
# in version control.
119-
# https://pdm.fming.dev/#use-with-ide
120-
.pdm.toml
119+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
120+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
121+
# pdm.lock
122+
# pdm.toml
123+
.pdm-python
124+
.pdm-build/
125+
126+
# pixi
127+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
128+
# pixi.lock
129+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
130+
# in the .venv directory. It is recommended not to include this directory in version control.
131+
.pixi
121132

122133
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
123134
__pypackages__/
@@ -126,11 +137,25 @@ __pypackages__/
126137
celerybeat-schedule
127138
celerybeat.pid
128139

140+
# Redis
141+
*.rdb
142+
*.aof
143+
*.pid
144+
145+
# RabbitMQ
146+
mnesia/
147+
rabbitmq/
148+
rabbitmq-data/
149+
150+
# ActiveMQ
151+
activemq-data/
152+
129153
# SageMath parsed files
130154
*.sage.py
131155

132156
# Environments
133157
.env
158+
.envrc
134159
.venv
135160
env/
136161
venv/
@@ -163,8 +188,35 @@ dmypy.json
163188
cython_debug/
164189

165190
# PyCharm
166-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
167-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
168-
# and can be added to the global gitignore or merged into this file. For a more nuclear
169-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
170-
#.idea/
191+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
192+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
193+
# and can be added to the global gitignore or merged into this file. For a more nuclear
194+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
195+
.idea/
196+
197+
# Abstra
198+
# Abstra is an AI-powered process automation framework.
199+
# Ignore directories containing user credentials, local state, and settings.
200+
# Learn more at https://abstra.io/docs
201+
.abstra/
202+
203+
# Visual Studio Code
204+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
205+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
206+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
207+
# you could uncomment the following to ignore the entire vscode folder
208+
# .vscode/
209+
210+
# Ruff stuff:
211+
.ruff_cache/
212+
213+
# PyPI configuration file
214+
.pypirc
215+
216+
# Marimo
217+
marimo/_static/
218+
marimo/_lsp/
219+
__marimo__/
220+
221+
# Streamlit
222+
.streamlit/secrets.toml

.pre-commit-config.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-ast
66
- id: check-yaml
@@ -26,7 +26,7 @@ repos:
2626
args: ["notebooks/"]
2727

2828
- repo: https://github.com/astral-sh/ruff-pre-commit
29-
rev: v0.11.0
29+
rev: v0.13.2
3030
hooks:
3131
- id: ruff
3232
types_or: [python, pyi, jupyter]
@@ -35,7 +35,16 @@ repos:
3535
types_or: [python, pyi, jupyter]
3636

3737
- repo: https://github.com/pre-commit/mirrors-mypy
38-
rev: v1.15.0
38+
rev: v1.18.2
3939
hooks:
4040
- id: mypy
41+
files: ^(src/|mypy/).+\.pyi?$
4142
args: [--strict]
43+
44+
- repo: https://github.com/codespell-project/codespell
45+
rev: v2.4.1
46+
hooks:
47+
- id: codespell
48+
args:
49+
- --ignore-words-list=HAX,ccompiler,ot,statics,whet,zar
50+
exclude: ^(mypy/test/|mypy/typeshed/|mypyc/test-data/|test-data/).+$

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Install uv
2+
FROM python:3.13-slim AS builder
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
4+
5+
# Change the working directory to the `app` directory
6+
WORKDIR /app
7+
8+
# Install dependencies
9+
RUN --mount=type=cache,target=/root/.cache/uv \
10+
# --mount=type=bind,source=uv.lock,target=uv.lock \
11+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
12+
uv sync --locked --no-install-project --no-editable
13+
14+
# Copy the project into the intermediate image
15+
ADD . /app
16+
17+
# Sync the project
18+
RUN --mount=type=cache,target=/root/.cache/uv \
19+
uv sync --no-editable
20+
21+
FROM python:3.13-slim
22+
23+
# Copy the environment, but not the source code
24+
COPY --from=builder --chown=app:app /app/.venv /app/.venv
25+
26+
# Run the application
27+
CMD ["/app/.venv/bin/python", "-m", "src.main"]

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ help: ## Show the help.
1111

1212
.PHONY: install
1313
install: ## Install dependencies
14+
@echo "Installing Python"
15+
uv python install 3.13
1416
@echo "Installing dependencies"
15-
poetry install
17+
uv sync --all-groups
1618
@echo "Installing pre-commit hooks"
17-
pre-commit install
19+
uv run pre-commit install
20+
@echo "Updating pre-commit hooks"
21+
uv run pre-commit autoupdate

pyproject.toml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
1-
[tool.poetry]
1+
[project]
22
name = "template-python"
33
version = "0.1.0"
4-
description = ""
5-
authors = ["Alejandro Uribe"]
4+
description = "Add your description here"
65
readme = "README.md"
7-
packages = [{include = "src"}]
8-
9-
[tool.poetry.dependencies]
10-
python = "^3.13"
11-
12-
13-
[tool.poetry.group.lint.dependencies]
14-
ruff = "^0.9.6"
15-
16-
[tool.poetry.group.dev.dependencies]
17-
pytest = "^8.3.4"
18-
pytest-cov = "^6.0.0"
19-
mypy = "^1.15.0"
20-
notebook = "^7.3.2"
21-
nbstripout = "^0.8.1"
22-
pre-commit = "^4.1.0"
23-
24-
25-
[build-system]
26-
requires = ["poetry-core>=2.0.0,<3.0.0"]
27-
build-backend = "poetry.core.masonry.api"
6+
requires-python = ">=3.13"
7+
dependencies = []
8+
9+
[dependency-groups]
10+
dev = [
11+
"notebook>=7.4.7",
12+
"pytest>=8.4.2",
13+
"pytest-cov>=7.0.0",
14+
"ipython>=9.4.0",
15+
]
16+
lint = [
17+
"mypy>=1.18.2",
18+
"pre-commit>=4.3.0",
19+
"ruff>=0.13.2",
20+
]
2821

2922
[tool.ruff]
3023
# Exclude a variety of commonly ignored directories.

src/.gitkeep

Whitespace-only changes.

src/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
def main() -> None:
1+
def main() -> str:
22
"""Main function of the program."""
3-
print("Hello World!")
3+
return "Hello World!"
44

55

66
if __name__ == "__main__":
7-
main()
7+
print(main())

0 commit comments

Comments
 (0)