refactor: Codacy code quality + dal-python 2026.9.5 - #3
Merged
Conversation
Frontend (Biome 2.5.12, governed by new frontend/biome.json which the Codacy Biome engine picks up): - add biome.json (line width 100 matching backend ruff, double quotes, semicolons) and npm lint/format scripts; @biomejs/biome devDependency - apply safe fixes across 56 files: formatting + import organization - CurveLabQuoteAuthoring: split the target/family effect and memoize invalidateCanonicalRequest so useExhaustiveDependencies passes with identical invalidation behavior - styles.css: drop the overridden duplicate .topbar background - CurveLabWorkspace: render the build stepper as semantic ol/li (a11y useAriaPropsSupportedByRole/useSemanticElements) - disable style/noDescendingSpecificity: every flagged selector pair is ancestor-disjoint, so the rule only yields false positives here Backend (radon cyclomatic complexity, behavior-preserving extraction): - curve_risk._execute_risk_run F(51) -> C(16): _RiskRunContext plus trade-to-node / jacobian / composed / key-rate / parallel helpers - curve_risk._admit_risk_run E(33) -> C(12): import-lineage, runtime document/axes, fixing-compatibility and method-fallback guards - curve_risk._runtime_dependencies C(19) -> guard helpers - dal_gateway.price_curve_lab_trades E(34) -> C(11): pricing-curves, xccy-market and aad-rows helpers; native call order unchanged - schemas CurveDraftDocumentInputV2._validate_topology D(23) -> A(4): populated / unique-keys / mode-roles / component-assignments split Verified: ruff clean, bandit clean, biome check clean (56 files), pytest 491 passed, vitest 101 passed, tsc + vite build pass.
Latest published wheel; upstream exposes quote risk through the public Python API and unifies the quote-risk GIL execution protocol. Verified against the real native binding: - app.native_runtime preflight passes - pytest 491 passed (fake dal) + 2 passed (native-marked) - async valuation completes with full AAD greeks - single-curve calibration completes and persists the curve DTO - Curve Lab draft -> build -> version -> risk run succeeds; trade-to-node matrix AVAILABLE via NATIVE_AAD_PARITY_VERIFIED - Playwright e2e: 4 passed on the native path, 21 passed with the canned test backend
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 8 |
| Duplication | 6 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
🔵 Needs a closer look
The backend refactors in Curve Lab risk/pricing are substantial and warrant careful human verification despite appearing behavior-preserving.
Pull request overview
This PR aligns the repo with Codacy’s configured quality gates (notably Biome for the frontend and complexity reductions in the backend) while also bumping the backend’s dal-python dependency to 2026.9.5.
Changes:
- Add Biome configuration + scripts/devDependency and apply automated formatting/lint fixes across the frontend (including tests and minor a11y-related markup/CSS tweaks).
- Refactor backend Curve Lab pricing/risk code to reduce complexity via helper extraction while keeping behavior stable.
- Bump backend
dal-pythonminimum version to2026.9.5and regenerate lockfiles.
File summaries
| File | Description |
|---|---|
| README.md | Updates documented dal-python minimum version. |
| frontend/vite.config.ts | Import order/style-only cleanup. |
| frontend/tests/unit/valuation_panel.test.tsx | Biome-driven formatting updates. |
| frontend/tests/unit/setup.ts | Import order/style-only cleanup. |
| frontend/tests/unit/quote_bump_panel.test.tsx | Biome-driven formatting updates. |
| frontend/tests/unit/models.test.tsx | Biome-driven formatting updates. |
| frontend/tests/unit/curves_quote_integration.test.tsx | Biome-driven formatting updates. |
| frontend/tests/unit/curve_run.test.tsx | Biome-driven formatting updates. |
| frontend/tests/unit/curve_lab_workspace.test.tsx | Biome-driven formatting updates. |
| frontend/tests/unit/curve_lab_utils.test.ts | Biome-driven formatting updates. |
| frontend/tests/unit/curve_lab_quote_authoring.test.tsx | Biome-driven formatting updates. |
| frontend/tests/unit/curve_builder_utils.test.ts | Biome-driven formatting updates. |
| frontend/tests/unit/api_client.test.ts | Biome-driven formatting updates. |
| frontend/tests/e2e/valuation.spec.ts | Biome-driven formatting updates. |
| frontend/tests/e2e/trades.spec.ts | Biome-driven formatting updates. |
| frontend/tests/e2e/product_builder.spec.ts | Biome-driven formatting updates. |
| frontend/tests/e2e/portfolios.spec.ts | Biome-driven formatting updates. |
| frontend/tests/e2e/models.spec.ts | Biome-driven formatting updates. |
| frontend/tests/e2e/dashboard.spec.ts | Biome-driven formatting updates. |
| frontend/tests/e2e/curves.spec.ts | Biome-driven formatting updates. |
| frontend/tests/e2e/curve_lab_workspace.spec.ts | Biome-driven formatting updates. |
| frontend/tests/e2e/app.spec.ts | Biome-driven formatting updates. |
| frontend/src/styles.css | Formatting + lifecycle list styling and minor cleanup. |
| frontend/src/pages/Valuations.tsx | Promise chain formatting/readability cleanup. |
| frontend/src/pages/Trades.tsx | Import consolidation + small readability refactor. |
| frontend/src/pages/ProductBuilder.tsx | Promise chain formatting/readability cleanup. |
| frontend/src/pages/Portfolios.tsx | Promise chain formatting/readability cleanup. |
| frontend/src/pages/Models.tsx | Promise chain formatting/readability cleanup. |
| frontend/src/pages/Dashboard.tsx | Promise chain formatting/readability cleanup. |
| frontend/src/pages/Curves.tsx | Formatting + minor readability refactors. |
| frontend/src/pages/CurveRun.tsx | Formatting + minor readability refactors. |
| frontend/src/main.tsx | Formatting-only tweak (trailing comma). |
| frontend/src/format.ts | Function signature formatting/readability. |
| frontend/src/curves/visualization.ts | Formatting-only refactor. |
| frontend/src/curves/examples.ts | Formatting-only refactor. |
| frontend/src/curves/curveLabUtils.ts | Formatting-only refactor. |
| frontend/src/curves/curveLabRegistry.ts | Formatting-only refactor. |
| frontend/src/curves/curveBuilderUtils.ts | Formatting-only refactor. |
| frontend/src/components/ValuationPanel.tsx | Formatting-only refactor. |
| frontend/src/components/QuoteBumpPanel.tsx | Formatting-only refactor. |
| frontend/src/components/MatrixHeatmap.tsx | Formatting-only refactor. |
| frontend/src/components/FitPlot.tsx | Formatting-only refactor. |
| frontend/src/components/CurvePreview.tsx | Formatting-only refactor. |
| frontend/src/components/CurveLabQuoteAuthoring.tsx | Hook dependency/invalidation refactor + formatting. |
| frontend/src/components/CalibrationLifecycle.tsx | Type-cast formatting cleanup. |
| frontend/src/App.tsx | Promise chain formatting/readability cleanup. |
| frontend/src/api/client.ts | Formatting-only refactor (no API shape change observed). |
| frontend/playwright.config.ts | Formatting-only refactor. |
| frontend/package.json | Adds Biome scripts + devDependency. |
| frontend/package-lock.json | Locks Biome dependency tree. |
| frontend/biome.json | New Biome configuration for Codacy/local lint/format. |
| backend/uv.lock | Locks dal-python to 2026.9.5 and updates metadata. |
| backend/requirements.txt | Raises dal-python floor to 2026.9.5. |
| backend/pyproject.toml | Raises dal-python floor to 2026.9.5. |
| backend/app/services/dal_gateway.py | Extracts pricing helpers to reduce complexity. |
| backend/app/services/curve_risk.py | Large refactor into helper functions/context objects to reduce complexity. |
| backend/app/schemas/curve_lab.py | Refactors topology validation into smaller helpers. |
Review details
Files not reviewed (1)
- frontend/package-lock.json: Generated file
- Files reviewed: 56/58 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- run ruff format over the refactored backend modules (CI gate) - Valuations: prefer-nullish-coalescing for the error fallback - split _validate_mode_roles per build mode (Lizard CCN 13 -> 4) - split _key_rate_dv01 success path (Lizard CCN 10 -> 4) - extract CurveBuilderStepper and derived-state helpers out of CurveLabWorkspace (Lizard CCN 9 -> 4)
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.
Summary
Two logical commits from one working session:
refactor: satisfy Codacy Biome rules and reduce backend complexity— code style + cyclomatic complexity per the repo's Codacy setup (bandit + Biome engines in.codacy.yml).chore(deps): bump dal-python from 2026.8.14 to 2026.9.5— latest published wheel; upstream exposes quote risk through the public Python API and unifies the quote-risk GIL execution protocol.Code quality (commit 1)
Frontend — new
frontend/biome.json(picked up by Codacy's Biome engine; line width 100 matching backend ruff),@biomejs/biomedevDependency +npm run lint/formatscripts:useExhaustiveDependencies: split target/family effects + memoizedinvalidateCanonicalRequestin CurveLabQuoteAuthoring (identical invalidation behavior).topbarbackground in styles.cssol/li(a11y)style/noDescendingSpecificitydisabled: all 48 flagged selector pairs are ancestor-disjoint → pure false positivesBackend — radon grades, behavior-preserving extraction (error payloads and native call order unchanged):
curve_risk._execute_risk_rundal_gateway.price_curve_lab_tradescurve_risk._admit_risk_runschemas._validate_topologycurve_risk._runtime_dependenciesNo D/E/F-graded functions remain (average A 2.86). Frontend cognitive complexity: 0 functions above 15.
Dependency bump (commit 2)
pyproject.toml/requirements.txtfloor raised todal-python>=2026.9.5,uv.lockregenerated, README version note updated.Verification
biome checkclean (56 files)tsc -b+vite buildpassapp.native_runtimepreflight OK; async valuation with full AAD greeks; single-curve calibration completed; Curve Lab draft → build → version → risk run succeeded with trade-to-node matrixAVAILABLE/NATIVE_AAD_PARITY_VERIFIEDDAL_PLAYWRIGHT_TEST_BACKEND=1