Parent issue
#194 — function purification
Problem
_handle_parquet_write_error (statements.py:800) has 5 parameters and multiple side effects:
- Mutates
batch_line dict in-place (lines 820-822)
- Mutates
error_message_list in-place (line 823)
- Prints to stdout (line 824)
- Prints to stderr via
traceback.print_exc() (line 825)
The caller must pass mutable containers and rely on in-place mutation for the result.
Proposal
Return an error dataclass or dict instead of mutating the inputs. Let the caller apply mutations. e.g. def build_parquet_error(name, pdf, exc) -> ParquetError. Move the prints to the caller or remove them.
Code relationships
Target function:
_handle_parquet_write_error() — statements.py:800
Callers (will need updating):
process_pdf_statement() — statements.py:828 (calls it 4 times, lines 971, 986, 1029)
Related:
batch_line dict — built in process_pdf_statement (line 900+), passed to update_parquet and update_db
PdfResult dataclass — data.py (the final result type)
Existing tests
None. No direct tests exist for _handle_parquet_write_error. Refactoring will not break any existing tests.
Siblings
Parent issue
#194 — function purification
Problem
_handle_parquet_write_error(statements.py:800) has 5 parameters and multiple side effects:batch_linedict in-place (lines 820-822)error_message_listin-place (line 823)traceback.print_exc()(line 825)The caller must pass mutable containers and rely on in-place mutation for the result.
Proposal
Return an error dataclass or dict instead of mutating the inputs. Let the caller apply mutations. e.g.
def build_parquet_error(name, pdf, exc) -> ParquetError. Move the prints to the caller or remove them.Code relationships
Target function:
_handle_parquet_write_error()—statements.py:800Callers (will need updating):
process_pdf_statement()—statements.py:828(calls it 4 times, lines 971, 986, 1029)Related:
batch_linedict — built inprocess_pdf_statement(line 900+), passed toupdate_parquetandupdate_dbPdfResultdataclass —data.py(the final result type)Existing tests
None. No direct tests exist for
_handle_parquet_write_error. Refactoring will not break any existing tests.Siblings