Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish to PyPI

on:
push:
tags:
- "v*"

jobs:
tests:
uses: ./.github/workflows/pythonpackage.yml

publish:
needs: tests
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Set version from tag
run: |
VERSION=${GITHUB_REF#refs/tags/v}
sed -i "s/^__version__ = .*/__version__ = \"${VERSION}\"/" us/version.py

- name: Build package
run: uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
67 changes: 33 additions & 34 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
name: Tests

on: [pull_request]
on:
pull_request:
workflow_call:

jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set Python environment
uses: actions/setup-python@v6

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: 3.14
architecture: x64
enable-cache: true
python-version: "3.14"

- name: Install dependencies
run: pip install -e .[dev]
run: uv sync

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

- name: Check code format with Black
run: black --check us
- name: Check code format with Ruff
run: uv run ruff format --check us

testing:
needs: linting
Expand All @@ -32,36 +33,34 @@ jobs:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -e .[dev]
- name: Test with pytest
run: |
pytest .
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync

- name: Test with pytest
run: uv run pytest .

building:
needs: linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set Python environment
uses: actions/setup-python@v6
with:
python-version: 3.14
architecture: x64

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

- name: Builds package
run: |
python -m build . -w -n
- name: Build package
run: uv build --wheel

- uses: actions/upload-artifact@v7
with:
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12
3.14
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ As per usual:
pip install us
```

or

```
uv install us
```


## Development

This project uses [uv](https://docs.astral.sh/uv/) for development.

```
uv sync
uv run pytest
uv run black --check us
```


## Features

Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ dependencies = ['jellyfish']
[project.scripts]
states = "us.cli.states:main"

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

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

[tool.black]
[tool.ruff]
line-length = 120
target-version = ['py38', 'py39', 'py310', 'py311', 'py312', 'py313', 'py314']
include = '\.pyi?$'
target-version = "py38"
2 changes: 1 addition & 1 deletion us/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
OBSOLETE, # noqa
) # noqa
from .unitedstatesofamerica import * # noqa
from .version import __version__ as version
from .version import __version__ as version # noqa
5 changes: 2 additions & 3 deletions us/unitedstatesofamerica.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name = "United States of America"
abbr = "US"

import datetime

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

__all__ = ["name", "abbr", "birthday"]
2 changes: 1 addition & 1 deletion us/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.2.0"
__version__ = "4.0.0.dev"
494 changes: 494 additions & 0 deletions uv.lock

Large diffs are not rendered by default.