Skip to content

Commit ce7af84

Browse files
authored
Migrate to uv and upgrade python to 3.13 (#130)
1 parent e5f017a commit ce7af84

14 files changed

Lines changed: 803 additions & 1264 deletions

File tree

.flake8

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
node-version: ['22']
17+
python-version: ['3.13']
1718
env:
1819
AWS_PROFILE: transitmatters
1920
AWS_DEFAULT_REGION: us-east-1
@@ -27,12 +28,11 @@ jobs:
2728
- name: Checkout repo
2829
uses: actions/checkout@v4
2930
- name: Set up Python
30-
uses: actions/setup-python@v2
31+
uses: actions/setup-python@v5
3132
with:
32-
python-version: 3.12
33-
- name: Install Poetry
34-
run: |
35-
curl -sSL https://install.python-poetry.org | python3 -
33+
python-version: ${{ matrix.python-version }}
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v5
3636
- name: Set up Node ${{ matrix.node-version }}.x
3737
uses: actions/setup-node@v4
3838
with:

.github/workflows/lint.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ jobs:
1212
strategy:
1313
matrix:
1414
node-version: ['20', '22']
15-
python-version: ['3.12']
15+
python-version: ['3.13']
1616
steps:
1717
- name: Checkout repo
1818
uses: actions/checkout@v4
1919
- name: Set up Python ${{ matrix.python-version }}
2020
uses: actions/setup-python@v5
2121
with:
2222
python-version: ${{ matrix.python-version }}
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v5
2325
- name: Set up Node ${{ matrix.node-version }}.x
2426
uses: actions/setup-node@v4
2527
with:
@@ -29,7 +31,6 @@ jobs:
2931
npx --yes package-lock-utd@1.1.0
3032
- name: Lint frontend code with ESLint
3133
run: |
32-
curl -sSL https://install.python-poetry.org | python3 -
3334
npm ci
3435
npm run lint-frontend
3536
@@ -38,23 +39,24 @@ jobs:
3839
strategy:
3940
matrix:
4041
node-version: ['20', '22']
41-
python-version: ['3.12']
42+
python-version: ['3.13']
4243
steps:
4344
- name: Checkout repo
4445
uses: actions/checkout@v4
4546
- name: Set up Python ${{ matrix.python-version }}
4647
uses: actions/setup-python@v5
4748
with:
4849
python-version: ${{ matrix.python-version }}
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v5
4952
- name: Set up Node ${{ matrix.node-version }}.x
5053
uses: actions/setup-node@v4
5154
with:
5255
node-version: ${{ matrix.node-version }}
5356
- name: Check if package-lock.json is up to date
5457
run: |
5558
npx --yes package-lock-utd@1.1.0
56-
- name: Lint backend code with Flake8
59+
- name: Lint backend code with Ruff
5760
run: |
58-
curl -sSL https://install.python-poetry.org | python3 -
5961
npm ci
6062
npm run lint-backend

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.14.3
4+
hooks:
5+
# Run the linter
6+
- id: ruff
7+
args: [--fix]
8+
types_or: [python, pyi]
9+
# Run the formatter
10+
- id: ruff-format
11+
types_or: [python, pyi]

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"recommendations": [
33
"dbaeumer.vscode-eslint",
44
"esbenp.prettier-vscode",
5-
"bradlc.vscode-tailwindcss"
5+
"bradlc.vscode-tailwindcss",
6+
"charliermarsh.ruff"
67
]
78
}

.vscode/settings.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
"typescript.enablePromptUseWorkspaceTsdk": true,
1010
"editor.formatOnSave": true,
1111
"python.analysis.typeCheckingMode": "off",
12-
"python.formatting.provider": "black",
1312
"[python]": {
14-
"editor.defaultFormatter": "ms-python.black-formatter"
15-
}
13+
"editor.defaultFormatter": "charliermarsh.ruff",
14+
"editor.codeActionsOnSave": {
15+
"source.fixAll.ruff": "explicit",
16+
"source.organizeImports.ruff": "explicit"
17+
}
18+
},
19+
"ruff.enable": true,
20+
"cSpell.words": ["chartjs", "MASSDOT", "MBTA", "slowzones"]
1621
}

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ This is the repository for the TransitMatters Shutdown Tracker. Client code is w
77
- node 22.x and npm 10+ required
88
- With `nvm` installed, use `nvm install && nvm use`
99
- verify with `node -v`
10-
- Python 3.12 with recent poetry (2.0.0 or later)
11-
- Verify with `python --version && poetry --version`
12-
- `poetry self update` to update poetry
13-
- If using `pyenv`, `pyenv install 3.12.0`
10+
- Python 3.13 with recent uv
11+
- [`uv`](https://docs.astral.sh/uv/)
12+
- Ensure `uv` is using the correct Python version by running `uv venv --python 3.13`
1413

1514
## Development Instructions
1615

deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ npm run build
3636

3737
# Deploy to cloudformation
3838
pushd server/ > /dev/null
39-
poetry export --without-hashes --output requirements.txt
40-
poetry run chalice package --stage $CHALICE_STAGE --merge-template cloudformation.json cfn/
39+
uv export --no-hashes --output-file requirements.txt
40+
uv run chalice package --stage $CHALICE_STAGE --merge-template cloudformation.json cfn/
4141
aws cloudformation package --template-file cfn/sam.json --s3-bucket $BACKEND_BUCKET --output-template-file cfn/packaged.yaml
4242
aws cloudformation deploy --template-file cfn/packaged.yaml --stack-name $STACK_NAME --capabilities CAPABILITY_IAM --no-fail-on-empty-changeset \
4343
--tags service=shutdown-tracker env=prod \

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"type": "module",
66
"scripts": {
77
"start": "concurrently npm:start-python npm:dev",
8-
"start-python": "cd server && poetry run chalice local --port=5555",
8+
"start-python": "cd server && uv run chalice local --port=5555",
99
"dev": "vite",
1010
"build": "tsc && vite build",
11-
"lint-frontend": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 10 && poetry run python sort-shutdowns.py --check",
12-
"lint-backend": "cd server && poetry run flake8 && poetry run black . --check",
11+
"lint-frontend": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 10 && uv run python sort-shutdowns.py --check",
12+
"lint-backend": "cd server && uv run ruff check .",
1313
"lint": "concurrently npm:lint-frontend npm:lint-backend",
14-
"sort-shutdowns": "poetry run python sort-shutdowns.py",
15-
"postinstall": "cd server && poetry install",
14+
"sort-shutdowns": "uv run python sort-shutdowns.py",
15+
"postinstall": "cd server && uv sync",
1616
"preview": "vite preview"
1717
},
1818
"engines": {

0 commit comments

Comments
 (0)