Update mirror.py to a uv script (#110)

<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

From my reading of the [UV
docs](https://docs.astral.sh/uv/guides/scripts/), `mirror.py` would be a
good example of a standalone script. This PR updates `mirror.py` and the
`main.yml` workflow to be a UV script and makes use of UV in the update
process.

## Test Plan

- Update the uv version (currently 0.8.4) to an older version e.g. 0.8.3
in both `pyproject.toml` and `README.md`
- Run `uv run --no-project mirror.py` to check the update process still
works as expected
This commit is contained in:
Calum Young 2024-12-30 15:48:39 +00:00 committed by GitHub
parent f0b5944bef
commit 6299d2ca23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 26 deletions

View File

@ -16,21 +16,15 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - name: Install uv
with: uses: astral-sh/setup-uv@v5
python-version: "3.11"
- name: download uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- run: uv pip install --system -r requirements-dev.txt
- name: set git config - name: set git config
run: | run: |
git config user.name "$GITHUB_ACTOR" git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- run: python mirror.py - run: uv run --no-project mirror.py
- name: check for unpushed commits - name: check for unpushed commits
id: check_unpushed id: check_unpushed

View File

@ -1,3 +1,12 @@
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "packaging==23.1",
# "urllib3==2.0.5",
# ]
# ///
"""Update ruff-pre-commit to the latest version of ruff."""
import re import re
import subprocess import subprocess
import tomllib import tomllib

View File

@ -4,9 +4,3 @@ version = "0.0.0"
dependencies = [ dependencies = [
"ruff==0.8.4", "ruff==0.8.4",
] ]
[project.optional-dependencies]
dev = [
"packaging~=23.1",
"urllib3>=2.0.5,<3.0.0",
]

View File

@ -1,11 +0,0 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --extra=dev --generate-hashes -o requirements-dev.txt --no-emit-package=ruff pyproject.toml
packaging==23.1 \
--hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \
--hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f
urllib3==2.0.5 \
--hash=sha256:13abf37382ea2ce6fb744d4dad67838eec857c9f4f57009891805e0b5e123594 \
--hash=sha256:ef16afa8ba34a1f989db38e1dbbe0c302e4289a47856990d0682e374563ce35e
# The following packages were excluded from the output:
# ruff