Parent issue
#194 — function purification
Problem
Parquet.__init__ (parquet.py:49) reads an existing parquet file from disk during construction (line 56), and deletes the file if the column layout mismatches (line 60). This means you cannot create a Parquet instance without a real file on disk.
Similarly, Parquet.create() (line 70), Parquet.update() (line 77), and Parquet.delete() (line 83) all write to disk as their primary action.
Proposal
Accept an optional pre-loaded DataFrame in the constructor instead of reading from disk. Move file I/O to a @classmethod from_file(cls, path) factory. Return DataFrames from create/update/delete and let the caller handle writing.
Code relationships
Target class:
Subclasses (will inherit changes):
ChecksAndBalances — parquet.py
StatementHeads — parquet.py
StatementLines — parquet.py
BatchHeads — parquet.py
BatchLines — parquet.py
Callers (will need updating):
update_parquet() — parquet.py:673
process_pdf_statement() — statements.py:828 (creates BatchLines, StatementHeads, etc.)
update_db() — database.py:387 (reads temp parquet files)
Existing tests
None. No direct tests exist for any Parquet class. Refactoring will not break any existing tests.
Siblings
Parent issue
#194 — function purification
Problem
Parquet.__init__(parquet.py:49) reads an existing parquet file from disk during construction (line 56), and deletes the file if the column layout mismatches (line 60). This means you cannot create aParquetinstance without a real file on disk.Similarly,
Parquet.create()(line 70),Parquet.update()(line 77), andParquet.delete()(line 83) all write to disk as their primary action.Proposal
Accept an optional pre-loaded
DataFramein the constructor instead of reading from disk. Move file I/O to a@classmethod from_file(cls, path)factory. Return DataFrames fromcreate/update/deleteand let the caller handle writing.Code relationships
Target class:
Parquet—parquet.py:49Subclasses (will inherit changes):
ChecksAndBalances—parquet.pyStatementHeads—parquet.pyStatementLines—parquet.pyBatchHeads—parquet.pyBatchLines—parquet.pyCallers (will need updating):
update_parquet()—parquet.py:673process_pdf_statement()—statements.py:828(creates BatchLines, StatementHeads, etc.)update_db()—database.py:387(reads temp parquet files)Existing tests
None. No direct tests exist for any Parquet class. Refactoring will not break any existing tests.
Siblings