Skip to content

fix: address quality scorecard findings (#873 #890 #891 #892) - #893

Merged
tschm merged 2 commits into
mainfrom
fix/quality-issues-890-893
Jul 17, 2026
Merged

fix: address quality scorecard findings (#873 #890 #891 #892)#893
tschm merged 2 commits into
mainfrom
fix/quality-issues-890-893

Conversation

@tschm

@tschm tschm commented Jul 17, 2026

Copy link
Copy Markdown
Member

Addresses four quality-scorecard issues.

#891 — Hoist function-local imports & document the accessor cycle

  • _portfolio_cost.py: import numpy as np and from ._stats._core import _std_is_negligible moved to module top. numpy is already a runtime dep (no lazy benefit) and _stats/_core doesn't import _portfolio_cost (no cycle) — _stats/_performance already imports it the same way.
  • data.py: each lazy accessor import (.plots, .stats, .reports, .utils) now carries a one-line comment stating it's intentionally deferred to break the data <-> accessors cycle, so it isn't "helpfully" hoisted later.

#892 — Stale template version in CLAUDE.md

  • CLAUDE.md now states template v1.2.0, matching .rhiza/template.lock / .rhiza/template.yml.

#873 — Semver / deprecation policy

  • docs/STABILITY.md already documents the semver guarantee and deprecation timeline for the Portfolio / Data public surface and is linked from the docs nav. This PR adds a reference to it from the README Documentation section so the policy is discoverable from the repo landing page too.

#890 — Test-layout parity

Tests here are deliberately organised by behaviour under tests/test_jquantstats/…, and per-module coverage is guaranteed by the 100% line+branch pytest gate (a stronger guarantee than 1:1 file mirroring). This PR opts out of the strict mirror rule via a documented [tool.check_test_layout] table in pyproject.toml (enforce = false + a reason).

⚠️ The opt-out only takes effect once the checker gains support for it — see Jebel-Quant/rhiza-claude#51. The added [tool.*] table is inert for every other tool until then, so this PR is safe to merge independently.

Verification

  • make typecheck — clean (ty + mypy strict).
  • make test — 1215 passed, 100% coverage.
  • make fmt — all pre-commit hooks pass (incl. pyproject validation).
  • New checker (from rhiza-claude#51) run against this repo exits 0 on both Python 3.9 (dependency-free fallback) and 3.11+ (tomllib).

🤖 Generated with Claude Code

- #891: hoist `numpy` and `_std_is_negligible` imports in `_portfolio_cost.py`
  to module top (numpy is already a runtime dep; no import cycle), and document
  each intentionally-deferred accessor import in `data.py` as breaking the
  data <-> accessors cycle.
- #892: update CLAUDE.md template version to v1.2.0 (matches .rhiza/template.lock).
- #873: link the existing API Stability / deprecation policy from README.
- #890: opt out of the rhiza 1:1 test-layout mirror via [tool.check_test_layout]
  (enforce=false + reason). Tests are organised by behaviour and per-module
  coverage is guaranteed by the 100% pytest gate. Requires the upstream
  rhiza-claude opt-out support (Jebel-Quant/rhiza-claude#51).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 17, 2026 17:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses multiple quality scorecard findings by clarifying import structure and architecture intent, updating template-version documentation, improving API stability policy discoverability, and documenting an intentional opt-out from strict test-layout mirroring.

Changes:

  • Hoisted function-local imports in _portfolio_cost.py and documented intentional deferred accessor imports in data.py.
  • Linked the API stability/deprecation policy from the README and updated the Rhiza template version reference in CLAUDE.md.
  • Added an inert (for now) [tool.check_test_layout] configuration block to document opting out of 1:1 test-file mirroring.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/jquantstats/data.py Adds explanatory comments for deferred accessor imports to prevent reintroducing circular-import issues.
src/jquantstats/_portfolio_cost.py Hoists numpy and _std_is_negligible imports to module scope to make dependencies explicit.
README.md Adds a prominent link to the published API stability & deprecation policy.
pyproject.toml Documents opting out of strict test-layout parity via a dedicated tool config table.
CLAUDE.md Updates the advertised Rhiza template version to match the repo’s synced version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/jquantstats/data.py
Comment on lines +523 to +525
# Deferred to break the data <-> accessors import cycle: _plots imports
# DataLike from this module, so hoisting this to module top re-forms the
# cycle. Keep the import local.
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