Parent issue
#194 — function purification
Problem
StatementBatch.__init__ (statements.py:1278) is a classic "constructor does too much" anti-pattern. On construction it:
- Calls
validate_or_initialise_project() which creates directories and DB files
- Calls
asyncio.run() / ProcessPoolExecutor for parallel processing
- Processes all PDFs (writing temp parquet files to disk)
- Prints timing summaries
You cannot create a StatementBatch object without actually processing PDFs. There is no way to construct one with mock data for testing.
Proposal
Make the constructor a pure data holder. Move processing into a separate process() or run() method. The constructor should store configuration; the method should execute the pipeline.
Code relationships
Target:
StatementBatch.__init__() — statements.py:1278
Callers (will need updating):
StatementBatch.__init__ in conftest.py (test fixture)
StatementBatch.__init__ in CLI handler (cli.py)
Related (called from init):
validate_or_initialise_project() — paths.py
process_pdf_statement() — statements.py:828
StatementBatch.__process_batch_sequential() — statements.py:1377
StatementBatch.__process_batch_turbo() — statements.py:1398
Existing tests:
tests/test_statements.py::TestGoodStatements — creates StatementBatch in conftest fixture
tests/conftest.py — session fixtures create StatementBatch objects
All existing tests will need updating to call batch.process() after construction.
Siblings
Parent issue
#194 — function purification
Problem
StatementBatch.__init__(statements.py:1278) is a classic "constructor does too much" anti-pattern. On construction it:validate_or_initialise_project()which creates directories and DB filesasyncio.run()/ProcessPoolExecutorfor parallel processingYou cannot create a
StatementBatchobject without actually processing PDFs. There is no way to construct one with mock data for testing.Proposal
Make the constructor a pure data holder. Move processing into a separate
process()orrun()method. The constructor should store configuration; the method should execute the pipeline.Code relationships
Target:
StatementBatch.__init__()—statements.py:1278Callers (will need updating):
StatementBatch.__init__inconftest.py(test fixture)StatementBatch.__init__in CLI handler (cli.py)Related (called from init):
validate_or_initialise_project()—paths.pyprocess_pdf_statement()—statements.py:828StatementBatch.__process_batch_sequential()—statements.py:1377StatementBatch.__process_batch_turbo()—statements.py:1398Existing tests:
tests/test_statements.py::TestGoodStatements— creates StatementBatch in conftest fixturetests/conftest.py— session fixtures create StatementBatch objectsAll existing tests will need updating to call
batch.process()after construction.Siblings