Skip to content

Commit e7cf37f

Browse files
authored
Prepare for 4.0.0 and switch to uv (#92)
* Update version to 4.0.0.dev * Switch to uv * Switch to ruff
1 parent f0531ff commit e7cf37f

9 files changed

Lines changed: 585 additions & 45 deletions

File tree

.github/workflows/publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
tests:
10+
uses: ./.github/workflows/pythonpackage.yml
11+
12+
publish:
13+
needs: tests
14+
runs-on: ubuntu-latest
15+
permissions:
16+
id-token: write
17+
steps:
18+
- uses: actions/checkout@v6
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v7
22+
23+
- name: Set version from tag
24+
run: |
25+
VERSION=${GITHUB_REF#refs/tags/v}
26+
sed -i "s/^__version__ = .*/__version__ = \"${VERSION}\"/" us/version.py
27+
28+
- name: Build package
29+
run: uv build
30+
31+
- name: Publish to PyPI
32+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/pythonpackage.yml

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
name: Tests
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
5+
workflow_call:
46

57
jobs:
68
linting:
79
runs-on: ubuntu-latest
810
steps:
911
- uses: actions/checkout@v6
10-
- name: Set Python environment
11-
uses: actions/setup-python@v6
12+
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v7
1215
with:
13-
python-version: 3.14
14-
architecture: x64
16+
enable-cache: true
17+
python-version: "3.14"
1518

1619
- name: Install dependencies
17-
run: pip install -e .[dev]
20+
run: uv sync
1821

19-
- name: Linting
20-
run: |
21-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
22-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
22+
- name: Lint with Ruff
23+
run: uv run ruff check .
2324

24-
- name: Check code format with Black
25-
run: black --check us
25+
- name: Check code format with Ruff
26+
run: uv run ruff format --check us
2627

2728
testing:
2829
needs: linting
@@ -32,36 +33,34 @@ jobs:
3233
matrix:
3334
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
3435
steps:
35-
- uses: actions/checkout@v6
36-
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v6
38-
with:
39-
python-version: ${{ matrix.python-version }}
40-
- name: Install dependencies
41-
run: |
42-
pip install -e .[dev]
43-
- name: Test with pytest
44-
run: |
45-
pytest .
36+
- uses: actions/checkout@v6
37+
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v7
40+
with:
41+
enable-cache: true
42+
python-version: ${{ matrix.python-version }}
43+
44+
- name: Install dependencies
45+
run: uv sync
46+
47+
- name: Test with pytest
48+
run: uv run pytest .
4649

4750
building:
4851
needs: linting
4952
runs-on: ubuntu-latest
5053
steps:
5154
- uses: actions/checkout@v6
52-
- name: Set Python environment
53-
uses: actions/setup-python@v6
54-
with:
55-
python-version: 3.14
56-
architecture: x64
5755

58-
- name: Install dependencies
59-
run: |
60-
pip install setuptools build wheel
56+
- name: Install uv
57+
uses: astral-sh/setup-uv@v7
58+
with:
59+
enable-cache: true
60+
python-version: "3.14"
6161

62-
- name: Builds package
63-
run: |
64-
python -m build . -w -n
62+
- name: Build package
63+
run: uv build --wheel
6564

6665
- uses: actions/upload-artifact@v7
6766
with:

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.12
1+
3.14

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ As per usual:
2525
pip install us
2626
```
2727

28+
or
29+
30+
```
31+
uv install us
32+
```
33+
34+
35+
## Development
36+
37+
This project uses [uv](https://docs.astral.sh/uv/) for development.
38+
39+
```
40+
uv sync
41+
uv run pytest
42+
uv run black --check us
43+
```
44+
2845

2946
## Features
3047

pyproject.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ dependencies = ['jellyfish']
2727
[project.scripts]
2828
states = "us.cli.states:main"
2929

30-
[project.optional-dependencies]
31-
dev = ['flake8', 'black', 'pytest', 'pytz']
30+
[dependency-groups]
31+
dev = ['ruff', 'pytest', 'pytz']
3232

3333
[tool.setuptools.dynamic]
3434
version = { attr = "us.version.__version__" }
3535

36-
[tool.black]
36+
[tool.ruff]
3737
line-length = 120
38-
target-version = ['py38', 'py39', 'py310', 'py311', 'py312', 'py313', 'py314']
39-
include = '\.pyi?$'
38+
target-version = "py38"

us/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
OBSOLETE, # noqa
88
) # noqa
99
from .unitedstatesofamerica import * # noqa
10-
from .version import __version__ as version
10+
from .version import __version__ as version # noqa

us/unitedstatesofamerica.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
name = "United States of America"
2-
abbr = "US"
3-
41
import datetime
52

3+
name = "United States of America"
4+
abbr = "US"
65
birthday = datetime.date(1776, 7, 4)
76

87
__all__ = ["name", "abbr", "birthday"]

us/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.2.0"
1+
__version__ = "4.0.0.dev"

uv.lock

Lines changed: 494 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)