Skip to content

Refactor: consolidate duplicated _elapsed_ms and remove one-liner wrapper#34

Merged
tommed merged 1 commit intomainfrom
claude/codebase-review-HBYM5
Apr 19, 2026
Merged

Refactor: consolidate duplicated _elapsed_ms and remove one-liner wrapper#34
tommed merged 1 commit intomainfrom
claude/codebase-review-HBYM5

Conversation

@tommed
Copy link
Copy Markdown
Contributor

@tommed tommed commented Apr 19, 2026

Summary

  • _elapsed_ms() was copy-pasted identically into all six validation check modules. Extracted to a new validation/_utils.py and replaced each local definition with an import.
  • BacktestEngine._parse_zone() was a one-line method that only called the module-level _parse_zone() with self._products[0]. Inlined and removed.

Changes

src/nexa_backtest/validation/_utils.py (new file)
Shared home for _elapsed_ms(start: float) -> int — the single source of truth.

6 validation modules (ruff_check, mypy_check, interface_check, lookahead_check, feature_check, resource_check)
Removed local _elapsed_ms definition, added from nexa_backtest.validation._utils import _elapsed_ms.

src/nexa_backtest/engines/backtest.py
Removed BacktestEngine._parse_zone() wrapper method. Inlined _parse_zone(self._products[0]) at the one call site.

Test plan

  • make ci passes — 727 tests, ruff check clean, ruff format clean

https://claude.ai/code/session_01XqYtc2t1oCV8eTmXN8aaiY

…pper

_elapsed_ms() was copy-pasted identically into all six validation check
modules (ruff_check, mypy_check, interface_check, lookahead_check,
feature_check, resource_check). Extracted to validation/_utils.py and
replaced each local definition with an import.

BacktestEngine._parse_zone() was a one-line wrapper that called the
module-level _parse_zone() function with self._products[0]. Inlined the
call at the single use site and removed the method.

https://claude.ai/code/session_01XqYtc2t1oCV8eTmXN8aaiY
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

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 reduces duplication in the validation subsystem by extracting a shared _elapsed_ms() helper into a single module, and simplifies the backtest engine by removing an unnecessary one-line wrapper method.

Changes:

  • Added validation/_utils.py as the shared home for _elapsed_ms(start: float) -> int.
  • Updated all six validation check modules to import _elapsed_ms instead of defining it locally.
  • Inlined BacktestEngine._parse_zone() usage at the only call site and removed the wrapper method.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/nexa_backtest/validation/_utils.py Introduces a shared _elapsed_ms() helper used across validation checks.
src/nexa_backtest/validation/ruff_check.py Replaces local _elapsed_ms implementation with an import from _utils.
src/nexa_backtest/validation/mypy_check.py Replaces local _elapsed_ms implementation with an import from _utils.
src/nexa_backtest/validation/interface_check.py Replaces local _elapsed_ms implementation with an import from _utils.
src/nexa_backtest/validation/lookahead_check.py Replaces local _elapsed_ms implementation with an import from _utils.
src/nexa_backtest/validation/feature_check.py Replaces local _elapsed_ms implementation with an import from _utils.
src/nexa_backtest/validation/resource_check.py Replaces local _elapsed_ms implementation with an import from _utils.
src/nexa_backtest/engines/backtest.py Inlines _parse_zone(self._products[0]) and removes the redundant wrapper method.

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

@tommed tommed merged commit c5b2dcd into main Apr 19, 2026
6 checks passed
@tommed tommed deleted the claude/codebase-review-HBYM5 branch April 19, 2026 18:41
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.

3 participants