Skip to content

chore: modernize analytics package tooling (uv, ruff, pyproject) #4934

Description

@NoopDog

Follow-up from #4927 / #4933, where a star-import re-export leak had the potential to break a consumer in a way no tooling caught.

Problem

The analytics package has no Python linting and legacy packaging:

  • No ruff/flake8/pylint config anywhere in the repo, and CI never runs against the Python code (deploy-analytics.yml only uploads the static gh-pages output).
  • Packaging is a bare setuptools setup.py with no pyproject.toml; dependencies are managed with pip + venv + a hand-pinned analytics/requirements.txt.

The star-import bug fixed in #4933 (report_elements.py re-exporting entities/_report_utils names, with fetch.py depending on the leak) is exactly what ruff's F403/F405 rules flag out of the box — it would have been caught at authoring time instead of costing an issue and a PR.

Suggested fix

  1. Add a pyproject.toml to analytics/analytics_package and move the setup.py metadata into it (setuptools setup.py-only packaging is deprecated, and ruff config wants a pyproject.toml anyway).
  2. Add ruff with a minimal config — defaults plus the F rules (F403/F405 are the ones that would have caught chore: make analytics package public exports explicit (remove star-import leak) #4927); run ruff check and ruff format --check clean on the existing code, fixing or explicitly ignoring what surfaces.
  3. Add a CI step to run-checks.yml (or a small dedicated workflow) that runs ruff on changes under analytics/** — a linter nobody runs is decoration.
  4. Migrate dependency management to uv: uv.lock replacing the hand-pinned analytics/requirements.txt, and update analytics/readme.md setup instructions accordingly.

Verification

  • ruff check passes locally and in CI; a deliberately introduced from x import * usage fails the check.
  • Fresh-venv generate_static_site.py run including historic_data_path, per the chore: retire legacy analytics formats — tracking #4913 verification convention, to confirm packaging changes didn't break the editable install.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions