Copilot commented on code in PR #3954:
URL: https://github.com/apache/iceberg-python/pull/3954#discussion_r3994707077
##########
pyiceberg/typedef.py:
##########
@@ -179,6 +179,9 @@ class Record(StructProtocol):
@classmethod
def _bind(cls, struct: StructType, **arguments: Any) -> Self:
+ field_names = {field.name for field in struct.fields}
+ if unknown_fields := arguments.keys() - field_names:
+ raise TypeError(f"Unexpected {cls.__name__} fields: {',
'.join(sorted(unknown_fields))}")
Review Comment:
This validation now makes the existing `DataFile.from_args` call in
`tests/integration/test_rest_manifest.py:92-110` fail because it passes
`format_version`, which is not a field in the selected data-file schema (the
constructor expects `_table_format_version`). Please update that caller or
otherwise account for it before rejecting unknown fields; otherwise the
integration test raises `TypeError: Unexpected DataFile fields: format_version`.
##########
pyiceberg/manifest.py:
##########
@@ -464,9 +464,14 @@ def data_file_with_partition(partition_type: StructType,
format_version: TableVe
class DataFile(Record):
@classmethod
- def from_args(cls, _table_format_version: TableVersion =
DEFAULT_READ_VERSION, **arguments: Any) -> DataFile:
+ def from_args(
+ cls, _table_format_version: TableVersion = DEFAULT_READ_VERSION, *,
spec_id: int | None = None, **arguments: Any
+ ) -> DataFile:
struct = DATA_FILE_TYPE[_table_format_version]
- return super()._bind(struct, **arguments)
+ data_file = super()._bind(struct, **arguments)
Review Comment:
The new strict binding makes an existing caller fail:
`tests/integration/test_rest_manifest.py:92` passes `format_version=2` to
`DataFile.from_args`, but this method only consumes `_table_format_version`, so
`format_version` remains in `arguments` and `_bind` now raises `TypeError`.
Please update that caller to the supported parameter name (or otherwise provide
an intentional compatibility alias).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]