Skip to content

Modernize project configuration and tooling#4

Merged
NorthIsUp merged 3 commits into
masterfrom
claude/modernize-python-repo-6rwUb
Apr 27, 2026
Merged

Modernize project configuration and tooling#4
NorthIsUp merged 3 commits into
masterfrom
claude/modernize-python-repo-6rwUb

Conversation

@NorthIsUp
Copy link
Copy Markdown
Owner

This PR modernizes the project's build system and development tooling by migrating from legacy setuptools configuration to modern Python packaging standards.

Summary

Replaced outdated setup.py and setup.cfg with a modern pyproject.toml configuration, updated CI/CD workflows, and migrated to uv and mise for dependency and task management.

Key Changes

Build System & Configuration:

  • Migrated from setup.py/setup.cfg to pyproject.toml with PEP 517/518 compliance
  • Configured hatchling as the build backend
  • Updated project metadata and dependencies (removed pystatsd requirement, made boto3 optional)
  • Added comprehensive tool configurations (ruff, pyright, pytest)

Development Tooling:

  • Added mise.toml for task automation and tool management
  • Configured uv as the package manager with preview features enabled
  • Added development task runners for common operations (test, lint, fmt, typecheck, build, publish)

CI/CD Workflows:

  • Added .github/workflows/ci.yaml for automated testing across Python 3.10-3.13
  • Added .github/workflows/release.yaml for automated PyPI publishing with OIDC trusted publishing
  • Removed legacy .travis.yml configuration

Code Quality:

  • Configured ruff with comprehensive linting rules (140 char line length, strict type checking)
  • Configured pyright for static type checking
  • Configured pytest with verbose output and debug logging

Python Version Support:

  • Updated to require Python 3.10+ (from Python 2.7+)
  • Added .python-version file specifying Python 3.13
  • Updated classifiers to reflect support for Python 3.10-3.13

Minor Code Updates:

  • Fixed Python 3 compatibility: basestringstr in measure/stats/stat.py
  • Fixed iteration issue in measure/client/__init__.py by wrapping globals().items() in list()

Documentation:

  • Updated README with development and release instructions
  • Updated CI badge from Travis CI to GitHub Actions
  • Updated .gitignore with modern Python and IDE patterns

Implementation Details

  • The release workflow automatically publishes to PyPI when pyproject.toml version changes on the default branch
  • Development tasks are centralized in mise.toml for consistency across environments
  • Ruff configuration is strict but pragmatic, with specific exclusions for test files and common patterns
  • The project now uses uv's lock file for reproducible builds

https://claude.ai/code/session_012GvH8TkBbcfKHnJLJA4jFj

claude added 3 commits April 27, 2026 20:30
- replace setup.py / setup.cfg / tox.ini with PEP 621 pyproject.toml
  using hatchling backend, modeled on NorthIsUp/north
- add uv.lock and switch dev workflow to uv
- add mise.toml with tasks for sync/test/lint/fmt/typecheck/build/publish
- replace .travis.yml with .github/workflows/ci.yaml (ruff + pytest matrix
  on py3.10–3.13 + build artefact) and a release.yaml that auto-publishes
  to PyPI via trusted publishing whenever the version in pyproject.toml
  changes on the default branch
- bring ruff/pyright/pytest config in line with the north reference repo
- drop py2 cruft so the package imports on modern Python:
  - fix dict-mutation-while-iterating in measure/client/__init__.py
  - replace basestring with str in measure/stats/stat.py
- update .gitignore and README to reflect the new toolchain
- ruff --fix: drop py2 `from __future__ import absolute_import`
  shims, sort imports, add `as Foo` re-exports in __init__ files
- ruff format: apply formatter to whole tree
- pyproject.toml: ignore RUF067/N816/TRY002/ANN205 globally and
  N802/COM818 in tests so legacy patterns (mixedCase import aliases,
  unittest-style camelCase test helpers, namedtuple's bare-tuple commas)
  don't fail the new lint job
- measure/client/boto3.py: chain re-raised KeyError with `from err`
…mer test

- bump requires-python to >=3.13; CI matrix is now 3.13 + 3.14
- drop ANN ignore noise from ruff; add modern PEP 604 / 695 typing
  annotations to every public function, method, and class in
  `measure/client/*` and `measure/stats/*`
- pyright: tighten reports, narrow `pythonVersion` to 3.13, exclude
  `tests/`, silence the intentional lazy-import cycles
- CI: run lint and typecheck through `uv run` so the project-pinned
  ruff/pyright versions are used (fixes the lint flake on the previous
  push where mise's `ruff = "latest"` produced different output)
- add a dedicated `typecheck` job (pyright)
- FakeStat MRO fix: explicitly set `FakeStat._stat_class = FakeStat`
  after the class is built so `FakeStat[k]` returns a FakeStat instead
  of inheriting `_stat_class = Timer` from `TimerDict` and producing a
  Timer with no `mark`. Unblocks 102 of the 126 pre-existing failures.
- pre-existing py2-era test bug: `Stats.apply` did `if func:` which
  triggered `__bool__` on the MagicMock; the test then filtered by the
  py2 magic name `__nonzero__` and crashed on the resulting record.
  Tighten production check to `is not None` (matches intent — the
  fallback was already `None`).
- drop dead `client/__init__.py` sentinel-removal loop (it never
  matched anything because the public clients are real classes, not
  the `*_Client = NotImplementedError` import-failure sentinels).
- pystatsd / boto3 client: clean import-fallback shape that works
  under pyright basic mode without resorting to `# type: ignore`.

Result: ruff check, ruff format --check, pyright measure, and the
full 457-test suite all pass on Python 3.13.
@NorthIsUp NorthIsUp merged commit 93c0a5d into master Apr 27, 2026
5 checks passed
@NorthIsUp NorthIsUp deleted the claude/modernize-python-repo-6rwUb branch April 27, 2026 22:50
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.

2 participants