Skip to content

chore: refactor store_files#42

Merged
eschmidt42 merged 4 commits into
mainfrom
chore/store
Jun 8, 2026
Merged

chore: refactor store_files#42
eschmidt42 merged 4 commits into
mainfrom
chore/store

Conversation

@eschmidt42

Copy link
Copy Markdown
Owner

This pull request introduces a new, type-safe system for tracking file operation outcomes in the fintl store workflow. It adds the FileCounts TypedDict and FileOutcome enum to standardize and centralize the way file operation results are counted and referenced across the codebase. The logic for processing individual files and accumulating results has been refactored to use these new types, improving maintainability and reducing the risk of mismatches between outcome names and count keys.

File outcome tracking improvements:

  • Added FileCounts (a TypedDict) and FileOutcome (a StrEnum) in the new module fintl.common.counts, and re-exported them from fintl.common.__init__. These types provide a single source of truth for file operation outcomes and their counts. [1] [2] [3]
  • Updated all relevant imports and function signatures to use FileCounts and FileOutcome instead of generic dict[str, int] and string keys. [1] [2] [3] [4]

Refactoring and logic changes:

  • Refactored the file processing logic in store_files by extracting _process_single_file, which returns a tuple of FileOutcome values for each file. The main loop now increments counts using these outcomes, ensuring consistency and reducing duplicated logic. [1] [2]
  • Improved the logging and variable naming for clarity, e.g., using dst_dir instead of raw_dir in _route_file.

Testing:

  • Added a new test (test_counts_and_outcomes_sync) to ensure that the keys in FileCounts and the members of FileOutcome always match, preventing future inconsistencies.

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.97%. Comparing base (c28f8ca) to head (f9bb65b).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #42   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files         103      105    +2     
  Lines        6952     6973   +21     
  Branches      220      221    +1     
=======================================
+ Hits         6950     6971   +21     
  Misses          1        1           
  Partials        1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 refactors the fintl store workflow’s result accounting by introducing centralized outcome/count types and updating the file-processing loop to use those types consistently.

Changes:

  • Added FileCounts (TypedDict) and FileOutcome (StrEnum) to standardize file operation outcome keys.
  • Refactored store_files by extracting _process_single_file() and accumulating counts from returned outcomes.
  • Added a test to keep FileCounts and FileOutcome in sync.

Reviewed changes

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

Show a summary per file
File Description
tests/common/test_counts.py Adds a sync test ensuring outcomes and count keys stay aligned.
src/fintl/etl/io/store.py Refactors store loop into _process_single_file and switches to typed outcome/count tracking.
src/fintl/common/counts.py Introduces the new FileCounts and FileOutcome types.
src/fintl/common/__init__.py Re-exports FileCounts/FileOutcome from fintl.common.
src/fintl/cli/commands/store/helper.py Updates console display helper signature to accept FileCounts.

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

Comment thread tests/common/test_counts.py Outdated
Comment thread src/fintl/common/counts.py Outdated
Comment thread src/fintl/etl/io/store.py
Comment thread src/fintl/etl/io/store.py
Comment thread src/fintl/etl/io/store.py
@eschmidt42 eschmidt42 merged commit 128259d into main Jun 8, 2026
1 check passed
@eschmidt42 eschmidt42 deleted the chore/store branch June 8, 2026 15:09
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