Skip to content

Commit 7c75fe0

Browse files
committed
ci: use uv/ruff for pypi/lint
1 parent 6ec7112 commit 7c75fe0

3 files changed

Lines changed: 44 additions & 34 deletions

File tree

.github/workflows/python-app.yml

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
# This workflow will install Python dependencies and lint with a single version of Python
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3-
4-
# This workflow will upload a Python Package using Twine when a release is created
5-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
6-
7-
# This workflow uses actions that are not certified by GitHub.
8-
# They are provided by a third-party and are governed by
9-
# separate terms of service, privacy policy, and support
10-
# documentation.
11-
12-
131
name: Python application
142

15-
163
on:
174
release:
185
types: [published]
@@ -23,30 +10,15 @@ permissions:
2310

2411
jobs:
2512
build:
26-
2713
runs-on: ubuntu-latest
2814
environment: release
2915
permissions:
3016
id-token: write
3117
steps:
3218
- uses: actions/checkout@v4
33-
- name: Set up Python 3.12
34-
uses: actions/setup-python@v3
35-
with:
36-
python-version: "3.12"
37-
- name: Install dependencies
38-
run: |
39-
python -m pip install --upgrade pip
40-
pip install flake8
41-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
42-
- name: Lint with flake8
43-
run: |
44-
# stop the build if there are Python syntax errors or undefined names
45-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
46-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
47-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
48-
- run: pip install -U wheel build
49-
- name: Build a binary wheel and a source tarball
50-
run: python -m build
51-
- name: Publish package distributions to PyPI
52-
uses: pypa/gh-action-pypi-publish@release/v1
19+
- uses: astral-sh/setup-uv@v7
20+
- name: Lint with ruff
21+
# ruff detects config from pyproject.toml
22+
run: uvx ruff check .
23+
- name: PyPI publish with uv
24+
run: uv publish

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ tests/util/local_auth.toml
1313
.venv
1414
identifier.sqlite
1515
obfuscated.sb3
16+
.pytest_cache
17+
.ruff_cache

pyproject.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,42 @@ scratch = "scratchattach.__main__:main"
5252
cli = ["rich-pixels"]
5353
lark = ["lark"]
5454

55+
[tool.ruff]
56+
line-length = 127
57+
exclude = [
58+
".bzr",
59+
".direnv",
60+
".eggs",
61+
".git",
62+
".git-rewrite",
63+
".hg",
64+
".ipynb_checkpoints",
65+
".mypy_cache",
66+
".nox",
67+
".pants.d",
68+
".pyenv",
69+
".pytest_cache",
70+
".pytype",
71+
".ruff_cache",
72+
".svn",
73+
".tox",
74+
".venv",
75+
".vscode",
76+
"__pypackages__",
77+
"_build",
78+
"buck-out",
79+
"build",
80+
"dist",
81+
"node_modules",
82+
"site-packages",
83+
"venv",
84+
]
85+
[tool.ruff.lint]
86+
select = ["E9", "F63", "F7", "F82", "C901"]
87+
88+
[tool.ruff.lint.mccabe]
89+
max-complexity = 10
90+
5591
[tool.setuptools.packages]
5692
find = { include = ["scratchattach"] }
5793

0 commit comments

Comments
 (0)