Skip to content

build: migrate to uv, pytest, ruff and pyrefly - #10

Merged
scottmckenzie merged 2 commits into
masterfrom
feature/migrate-to-uv
Oct 15, 2026
Merged

scottmckenzie merged 2 commits into
masterfrom
feature/migrate-to-uv

Conversation

@scottmckenzie

Copy link
Copy Markdown
Owner

Summary

Moves the project from setuptools to uv, and adds a test suite, linting, type checking and CI.

Packaging

  • setup.py and setup.cfg are replaced by pyproject.toml (hatchling backend), managed with uv. uv.lock is committed.
  • Name, version (0.1.0), the gatt>=0.2.7 dependency and the holmanctl command are unchanged. download_url is dropped.
  • requires-python = ">=3.9" (the README previously said 3.4+).
  • The wheel contains only holman/ and holmanctl.py.

Tests (tests/, 27 tests, 81% coverage)

  • The real gatt exits on import without python3-dbus, so tests/conftest.py swaps in an in-memory fake. Tests need no dbus, bluetoothd, root or hardware.
  • Covers service/characteristic discovery for both models, connect-failure paths, the on/off state byte, start/stop bytes (including the 255-minute cap), "Tap Timer" alias filtering, de-duplicated discovery, and the holmanctl listeners and --known output.

Lint and types

  • ruff lint and format. Most of the diff in holman/holman.py and holmanctl.py is formatting, including the Python examples in README.md.
  • pyrefly, with a small stub at typings/gatt/__init__.pyi. gatt picks its backend at runtime, which the checker can't narrow, so the stub pins it to BlueZ.

Bug fixes

  • TapTimer.services_resolved() called self.listener.connect_failed() without checking for a listener, so it crashed when a characteristic was missing and no listener was set.
  • The missing-characteristic errors were built as Exception("... %s missing", uuid), so the UUID was never inserted into the message.

Other changes

  • holmanctl listeners stop the manager through tap_timer.manager instead of a module global.
  • holman/__init__.py declares __all__.

CI (.github/workflows/ci.yml)

  • Lint and type check, pytest on Python 3.9 and 3.14, and uv build. Every job uses uv sync --locked, so a stale lock file fails CI.

Docs

  • README has a Development section with the uv commands, and setup for hardware testing (uv venv --system-site-packages --python /usr/bin/python3, so the apt-installed dbus and gi are visible).
  • CLAUDE.md is added, covering the uv workflow, checks, layout and the Python 3.9 minimum.

Test plan

  • uv run pytest passes on Python 3.9, 3.12 and 3.14
  • uv run ruff check . and uv run ruff format --check .
  • uv run pyrefly check (0 errors)
  • uv build, with wheel and sdist contents checked
  • CI passes on this PR (first run of the workflow)
  • Hardware: sudo .venv/bin/holmanctl --discover and --connect <MAC> against a real tap timer

🤖 Generated with Claude Code

https://claude.ai/code/session_01T53VSjKogcDk3z3avG76Ay

scottmckenzie and others added 2 commits October 15, 2026 17:34
Replace setup.py/setup.cfg with a pyproject.toml (hatchling backend)
managed by uv, and add a dev dependency group with pytest, ruff and
pyrefly.

- Add a pytest suite that swaps gatt for an in-memory fake, so tests
  run without dbus, bluetoothd or hardware
- Add a gatt type stub that pins pyrefly to the BlueZ backend
- Apply ruff formatting and lint fixes; export the public API via __all__
- Guard listener calls in TapTimer.services_resolved(), which crashed
  when no listener was set, and fix the missing-characteristic error
  messages, which never interpolated the UUID
- holmanctl listeners stop the manager via tap_timer.manager instead
  of a module global
- Add a CI workflow running lint, type check, tests on Python 3.9 and
  3.14, and a build
- Document the uv workflow in README.md and CLAUDE.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T53VSjKogcDk3z3avG76Ay
Match requires-python, the ruff/pyrefly targets and the CI matrix, and
list which newer syntax is unavailable on 3.9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T53VSjKogcDk3z3avG76Ay
@scottmckenzie
scottmckenzie merged commit 2cb5c06 into master Oct 15, 2026
4 checks passed
@scottmckenzie
scottmckenzie deleted the feature/migrate-to-uv branch October 15, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant