Skip to content

refactor: Unify OperationType and Action enums #53

@przemyslawbialon

Description

@przemyslawbialon

Labels: refactor, good first issue, correctness
Priority: P1
Blocked by: #4 (plugin ABC refactor will touch these same files)

Context

Per TAX_LAW_AUDIT.md Issue #1: pit38/plugins/stock/revolut/transaction_row_parser.py:31 returns OperationType.BUY but Transaction expects Action.BUY. The code works only because both enums have the same .value = "BUY". This is fragile — any change to either enum breaks silently without a type error.

Good first issue for a Python developer because:

  • Scope is narrow (two enums, handful of files)
  • No tax-logic understanding needed
  • Clear success criterion (mypy passes, tests pass)

Acceptance Criteria

Technical Approach

Preferred: one enum. Look for all uses of OperationType and Action via grep -r "OperationType\|Action" pit38/. If the two enums have identical values, delete one and update all imports.

Alternative if semantics differ:

# pit38/domain/transactions/action.py
from enum import Enum

class Action(str, Enum):
    BUY = "BUY"
    SELL = "SELL"
    DIVIDEND = "DIVIDEND"
    # ... all values

# pit38/plugins/stock/revolut/transaction_row_parser.py
# Before: returns OperationType.BUY (wrong type, works by accident)
# After:
def _operation_type(row) -> Action:
    return Action[row["Type"].upper()]  # explicit parse

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions