Skip to content

Pass Box and csv reader options through BoxList.from_csv - #371

Open
youdie006 wants to merge 1 commit into
cdgriffith:developfrom
youdie006:fix-csv-box-options
Open

youdie006 wants to merge 1 commit into
cdgriffith:developfrom
youdie006:fix-csv-box-options

Conversation

@youdie006

Copy link
Copy Markdown

box_from_file passes its keyword arguments on to the format's loader, but BoxList.from_csv is the only from_* method that takes none, so any option on a CSV file raises:

box_from_file("rows.json", frozen_box=True)   BoxList, frozen
box_from_file("rows.csv", frozen_box=True)    TypeError: BoxList.from_csv() got an unexpected keyword argument 'frozen_box'
BoxList.from_csv(text, delimiter=";")         TypeError: BoxList.from_csv() got an unexpected keyword argument 'delimiter'

from_csv now splits the options the way from_json, from_msgpack and the others do: Box options go to the BoxList, the rest to csv.DictReader. The string branch of _from_csv passes the reader options too; the file branch already did. Calls without options are unchanged.

The two new tests fail on develop with the TypeError above. The full suite passes on Python 3.13 in pure Python (100% line and branch coverage) and with the Cython build (uv pip install -e . --no-build-isolation); ruff 0.17.3 check and format, and mypy, pass.

Written with AI assistance (Claude); I have reviewed the change.

box_from_file passes its keyword arguments to BoxList.from_csv like it does for
the other formats, but from_csv took none, so any option raised TypeError. It
now splits Box options from csv.DictReader options like the other from_* methods,
and the string branch of _from_csv passes the reader options too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant