Skip to content

Commit c3b1410

Browse files
committed
switch from black to ruff and use uv overall
1 parent 8b5a5f2 commit c3b1410

15 files changed

+539
-68
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,12 @@ jobs:
99
id-token: write
1010
steps:
1111
- uses: actions/checkout@v4
12-
- name: Set up Python
13-
uses: actions/setup-python@v5
12+
- name: Set up uv
13+
uses: astral-sh/setup-uv@v5
1414
with:
1515
python-version: "3.x"
16-
- name: Install pypa/build
17-
run: >-
18-
python3 -m
19-
pip install
20-
build
21-
--user
2216
- name: Build a binary wheel and a source tarball
23-
run: >-
24-
python3 -m
25-
build
26-
--sdist
27-
--wheel
28-
--outdir dist/
29-
.
17+
run: uv build
3018
- name: Publish distribution 📦 to PyPI
3119
if: startsWith(github.ref, 'refs/tags')
32-
uses: pypa/gh-action-pypi-publish@release/v1
20+
run: uv publish

.github/workflows/python-test.yml

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,42 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v4
20-
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v5
20+
- name: Set up uv
21+
uses: astral-sh/setup-uv@v5
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
- name: Install dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
python -m pip install flake8 pytest mypy
28-
- name: Lint with flake8
25+
run: uv sync --group dev
26+
- name: Lint with ruff
2927
run: |
3028
# stop the build if there are Python syntax errors or undefined names
31-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29+
uv run ruff check .
3230
- name: Check with mypy
33-
run: mypy pythonosc examples
31+
run: uv run mypy pythonosc examples
3432
- name: Test with pytest
35-
run: pytest
33+
run: uv run pytest
3634
lint:
3735
runs-on: ubuntu-latest
3836
steps:
39-
- uses: actions/checkout@v3
40-
- uses: psf/black@stable
37+
- uses: actions/checkout@v4
38+
- name: Set up uv
39+
uses: astral-sh/setup-uv@v5
40+
- name: Run ruff format
41+
run: uv run ruff format --check .
4142

4243
check-types-published:
4344
runs-on: ubuntu-latest
4445
steps:
45-
- uses: actions/checkout@v3
46-
- uses: actions/setup-python@v5
46+
- uses: actions/checkout@v4
47+
- name: Set up uv
48+
uses: astral-sh/setup-uv@v5
4749
with:
4850
python-version: '3.12'
49-
- run: |
50-
pip install build
51-
python -m build --sdist --wheel
52-
51+
- name: Build package
52+
run: uv build
53+
- name: Verify package installation and types
54+
run: |
5355
temp=$(mktemp -d)
54-
55-
python -m venv $temp/venv
56-
source $temp/venv/bin/activate
57-
58-
pip install mypy ./dist/*whl
59-
60-
cd $temp
61-
62-
echo 'import pythonosc' > demo.py
63-
mypy demo.py
56+
uv run --with mypy --with ./dist/*.whl --no-project -- python -c "import pythonosc"
57+
echo 'import pythonosc' > $temp/demo.py
58+
uv run --with mypy --with ./dist/*.whl --no-project -- mypy $temp/demo.py

examples/async_server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ async def loop():
2424

2525
async def init_main():
2626
server = AsyncIOOSCUDPServer((ip, port), dispatcher, asyncio.get_event_loop())
27-
transport, protocol = (
27+
(
28+
transport,
29+
protocol,
30+
) = (
2831
await server.create_serve_endpoint()
2932
) # Create datagram endpoint and start serving
3033

examples/simple_echo_server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66

77
import argparse
8-
import math
98

109
from pythonosc.dispatcher import Dispatcher
1110
from pythonosc import osc_server

pyproject.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["setuptools"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["uv-build"]
3+
build-backend = "uv_build"
44

55
[project]
66
name = "python-osc"
@@ -21,10 +21,23 @@ classifiers = [
2121
"Topic :: Multimedia :: Sound/Audio",
2222
"Topic :: System :: Networking",
2323
]
24+
dependencies = []
2425

2526
[project.urls]
2627
Repository = "https://github.com/attwad/python-osc"
2728

29+
[dependency-groups]
30+
dev = [
31+
"pytest",
32+
"mypy",
33+
"ruff",
34+
"pytest-cov",
35+
]
36+
37+
[tool.uv.build-backend]
38+
module-name = "pythonosc"
39+
module-root = "."
40+
2841
[tool.mypy]
2942
# Would be great to turn this on, however there's too many cases it would break
3043
# right now.

pythonosc/dispatcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ async def async_call_handlers_for_packet(
350350
)
351351
if result:
352352
results.append(result)
353-
except osc_packet.ParseError as e:
353+
except osc_packet.ParseError:
354354
pass
355355
return results
356356

pythonosc/osc_message_builder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ def build(self) -> osc_message.OscMessage:
195195

196196
def build_msg(address: str, value: ArgValue = "") -> osc_message.OscMessage:
197197
builder = OscMessageBuilder(address=address)
198-
values: ArgValue
199198
if value == "":
200199
values = []
201200
elif not isinstance(value, Iterable) or isinstance(value, (str, bytes)):

pythonosc/osc_packet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ def __init__(self, dgram: bytes) -> None:
7272
else:
7373
# Empty packet, should not happen as per the spec but heh, UDP...
7474
raise ParseError(
75-
"OSC Packet should at least contain an OscMessage or an "
76-
"OscBundle."
75+
"OSC Packet should at least contain an OscMessage or an OscBundle."
7776
)
7877
except (osc_bundle.ParseError, osc_message.ParseError) as pe:
7978
raise ParseError(f"Could not parse packet {pe}")

pythonosc/test/test_osc_bundle.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
b"?\x00\x00\x00"
4747
)
4848

49-
_DGRAM_EMPTY_BUNDLE = b"#bundle\x00" b"\x00\x00\x00\x00\x00\x00\x00\x01"
49+
_DGRAM_EMPTY_BUNDLE = b"#bundle\x00\x00\x00\x00\x00\x00\x00\x00\x01"
5050

5151
_DGRAM_BUNDLE_IN_BUNDLE = (
5252
b"#bundle\x00"
@@ -60,20 +60,14 @@
6060
b"?\x00\x00\x00"
6161
)
6262

63-
_DGRAM_INVALID = b"#bundle\x00" b"\x00\x00\x00"
63+
_DGRAM_INVALID = b"#bundle\x00\x00\x00\x00"
6464

6565
_DGRAM_INVALID_INDEX = (
66-
b"#bundle\x00"
67-
b"\x00\x00\x00\x00\x00\x00\x00\x01"
68-
b"\x00\x00\x00\x20"
69-
b"/SYNC\x00\x00\x00\x00"
66+
b"#bundle\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x20/SYNC\x00\x00\x00\x00"
7067
)
7168

7269
_DGRAM_UNKNOWN_TYPE = (
73-
b"#bundle\x00"
74-
b"\x00\x00\x00\x00\x00\x00\x00\x01"
75-
b"\x00\x00\x00\x10"
76-
b"iamnotaslash"
70+
b"#bundle\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x10iamnotaslash"
7771
)
7872

7973

pythonosc/test/test_osc_message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from datetime import datetime
66

77
# Datagrams sent by Reaktor 5.8 by Native Instruments (c).
8-
_DGRAM_KNOB_ROTATES = b"/FB\x00" b",f\x00\x00" b">xca=q"
8+
_DGRAM_KNOB_ROTATES = b"/FB\x00,f\x00\x00>xca=q"
99

10-
_DGRAM_SWITCH_GOES_OFF = b"/SYNC\x00\x00\x00" b",f\x00\x00" b"\x00\x00\x00\x00"
10+
_DGRAM_SWITCH_GOES_OFF = b"/SYNC\x00\x00\x00,f\x00\x00\x00\x00\x00\x00"
1111

12-
_DGRAM_SWITCH_GOES_ON = b"/SYNC\x00\x00\x00" b",f\x00\x00" b"?\x00\x00\x00"
12+
_DGRAM_SWITCH_GOES_ON = b"/SYNC\x00\x00\x00,f\x00\x00?\x00\x00\x00"
1313

1414
_DGRAM_NO_PARAMS = b"/SYNC\x00\x00\x00"
1515

0 commit comments

Comments
 (0)