Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The refactor consistently preserves stored string behavior and includes focused compatibility coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Replaces correction action constants with a typed Action StrEnum while preserving persisted values and behavior.
Changes:
- Introduces
Actionand updates correction, form, view, and replication APIs. - Retains raw-string compatibility for persisted logs.
- Adds enum compatibility and filtering tests.
| File | Description |
|---|---|
src/datasure/processing/correction_log.py |
Defines Action and data-changing actions. |
src/datasure/processing/corrections.py |
Uses typed actions throughout correction processing. |
src/datasure/utils/correction_form.py |
Types form actions with the enum. |
src/datasure/views/correction_view.py |
Updates the correction handler signature. |
src/datasure/replication/script_generators.py |
Uses enum members during script generation. |
src/datasure/replication/package_builder.py |
Excludes accept records using the enum. |
tests/processing/test_correction_log.py |
Tests stored values and compatibility. |
tests/views/test_view_logic.py |
Uses the canonical action vocabulary. |
docs/ARCHITECTURE.md |
Documents enum ownership. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
iabaako
added this pull request to stack #313
September 30, 2026 20:07
4 tasks
… StrEnum
Replace MODIFY_VALUE_ACTION, REMOVE_VALUE_ACTION, REMOVE_ROW_ACTION and
ACCEPT_ACTION with members of a single `Action` StrEnum in
correction_log.py, and define CORRECTION_ACTIONS from its members.
Signatures, CorrectionEntry and CorrectionFormState now take
`action: Action`.
Member values equal the strings already stored in corr_log_{alias}, and
StrEnum members compare equal to them, so existing logs load and replay
unchanged and the generated Stata script is byte-for-byte identical.
`_emit_stata` keeps `action: str` because it reads raw log values, and
coercing with `Action(...)` would raise on unknown values that are
skipped today.
Closes #310
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iabaako
force-pushed
the
refactor/310-action-strenum
branch
from
October 9, 2026 22:27
c1dc6b8 to
c3397c3
Compare
|
This branch has not been deployed
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.



Pull Request Summary 🚀
What does this PR do? 📝
Replaces the correction action string constants with a single
ActionStrEnumincorrection_log.py. Behaviour does not change.Merge danger. This is a two-way door: no stored value changes and no migration is needed, so a revert is clean. Blast radius: type-level. Only the
*_ACTIONnames change, and they exist only on the unreleased #307 branch.Why is this change needed? 🤔
The action vocabulary was plain
str. A typo or an unknown action was only caught at runtime, if at all. The check-page sub-issues of #295 (#302, #303, #304) are about to add actions, and each one can now be added as an enum member.How was this implemented? 🛠️
corr_log_{alias}tables.StrEnummembers compare equal to those strings andstr()returns them. So existing logs load, filter (pl.col("action") == Action.ACCEPT), display and replay unchanged._apply_entrychecksentry.action not in CORRECTION_ACTIONSinstead of an inline tuple._emit_stata,_describe_correction_rowand the replay loop receive raw strings from saved logs, so they still takestr. Converting withAction(...)would raise on unknown values that are skipped today.matchstatement or shared mapping (scope item 4) is not done. It would grow the diff, and Corrections: replace action string constants with an Action StrEnum in correction_log.py #310 says to leave it out in that case. The remaining duplication is between_apply_actionand the replay loop incorrections.py.docs/ARCHITECTURE.mdnow notes thatcorrection_log.pyowns theActionenum.How to test or reproduce ? 🧪
just test: 3348 passed, 6 skipped.uv run python -m pytest tests/processing/test_correction_log.pyruns new tests for the stored values, round-trip,str()output,CORRECTION_ACTIONSmembership and a polars filter on a saved log.generate_corrections_scriptoutput from the same log (modify value, remove value, remove row, accept, and an unknown action) on the base branch and on this branch.cmpfound no difference.src/:grep -rnE '"(modify value|remove value|remove row|accept)"' srcmatches only the enum definition, docstrings and onboarding help text.Screenshots (if applicable) 📷
N/A. No UI changes.
Checklist ✅
Reviewer Emoji Legend
:code::smiley::+1::100:...and I want the author to know it! This is a way to highlight positive parts of a code review.
:star: :star: :star:And I am providing reasons why it needs to be addressed as well as suggested improvements.
:star: :star:And I am providing suggestions where it could be improved either in this PR or later.
:star:...and consider this a suggestion, not a requirement.
:question:This should be a fully formed question with sufficient information and context that requires a response.
:memo::pick:This does not require any changes and is often better left unsaid. This may include stylistic, formatting, or organization suggestions and should likely be prevented/enforced by linting if they really matter
:recycle:Should include enough context to be actionable and not be considered a nitpick.
🤖 Generated with Claude Code