Modernize project configuration and tooling#4
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pyandsetup.cfgwith a modernpyproject.tomlconfiguration, updated CI/CD workflows, and migrated touvandmisefor dependency and task management.Key Changes
Build System & Configuration:
setup.py/setup.cfgtopyproject.tomlwith PEP 517/518 compliancehatchlingas the build backendpystatsdrequirement, madeboto3optional)Development Tooling:
mise.tomlfor task automation and tool managementuvas the package manager with preview features enabledCI/CD Workflows:
.github/workflows/ci.yamlfor automated testing across Python 3.10-3.13.github/workflows/release.yamlfor automated PyPI publishing with OIDC trusted publishing.travis.ymlconfigurationCode Quality:
ruffwith comprehensive linting rules (140 char line length, strict type checking)pyrightfor static type checkingpytestwith verbose output and debug loggingPython Version Support:
.python-versionfile specifying Python 3.13Minor Code Updates:
basestring→strinmeasure/stats/stat.pymeasure/client/__init__.pyby wrappingglobals().items()inlist()Documentation:
.gitignorewith modern Python and IDE patternsImplementation Details
pyproject.tomlversion changes on the default branchmise.tomlfor consistency across environmentshttps://claude.ai/code/session_012GvH8TkBbcfKHnJLJA4jFj