Skip to content

make the default value of first_key hashable #5214

@wyli

Description

@wyli

Is your feature request related to a problem? Please describe.
the default of first_key is an empty list which is not hashable:

def first_key(self, data: Dict[Hashable, Any]):
"""
Get the first available key of `self.keys` in the input `data` dictionary.
If no available key, return an empty list `[]`.
Args:
data: data that the transform will be applied to.
"""
return first(self.key_iterator(data), [])

this makes the regular usage: data_dict[first_key(d)] always raises a static type checking error about not hashable.

Revising the default value might resolve this issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions