Skip to content

Fix add_column parameter order so feature precedes new_fingerprint#8306

Open
gaurav0107 wants to merge 1 commit into
huggingface:mainfrom
gaurav0107:fix/7864-add-column-and-add-item-erroneously-requ
Open

Fix add_column parameter order so feature precedes new_fingerprint#8306
gaurav0107 wants to merge 1 commit into
huggingface:mainfrom
gaurav0107:fix/7864-add-column-and-add-item-erroneously-requ

Conversation

@gaurav0107

Copy link
Copy Markdown

What

Dataset.add_column's signature is (name, column, new_fingerprint=None, feature=None), but:

  • its own docstring documents the third argument as feature (not new_fingerprint), and
  • every sibling @fingerprint_transform method keeps new_fingerprint as the last parameter (e.g. cast_column(column, feature, new_fingerprint=None), rename_column, remove_columns, select_columns).

Because new_fingerprint sits before feature, a docstring-conformant positional call raises:

>>> from datasets import Dataset, Value
>>> ds = Dataset.from_dict({"a": [1, 2]})
>>> ds.add_column("b", [3, 4], Value("int32"))
TypeError: Dataset.add_column() got multiple values for argument 'new_fingerprint'

The fingerprint_transform decorator injects new_fingerprint as a keyword argument, so the positional value collides with it.

Fix

Reorder the signature to (name, column, feature=None, new_fingerprint=None), matching the docstring and the cast_column convention. The decorator references new_fingerprint by keyword, so this is safe for existing keyword callers, and no Dataset.add_column caller in the repo passes feature/new_fingerprint positionally.

Test

Added test_add_column_feature_argument in tests/test_arrow_dataset.py, asserting that a positional feature is honored, the keyword form still works, and the new_fingerprint keyword is still respected. The test fails on main (TypeError) and passes with this change.

Fixes #7864


🤖 Opened with Superhuman, an open-source contribution agent.

Dataset.add_column documents `feature` as its third argument and every
sibling @fingerprint_transform method (cast_column, rename_column,
remove_columns, select_columns, ...) keeps `new_fingerprint` as the last
parameter. add_column had them reversed, so a docstring-conformant
positional call `ds.add_column(name, column, feature)` raised
"TypeError: got multiple values for argument 'new_fingerprint'" because
the fingerprint_transform decorator injects new_fingerprint by keyword.

Reorder the signature to (name, column, feature=None, new_fingerprint=None).
The decorator references new_fingerprint by keyword, so this is safe for
existing keyword callers, and no add_column caller passes feature or
new_fingerprint positionally.

Fixes huggingface#7864
@gaurav0107 gaurav0107 marked this pull request as ready for review July 5, 2026 22:56
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.

add_column and add_item erroneously(?) require new_fingerprint parameter

1 participant