Skip to content

Commit

Permalink
Remove early checking of field type
Browse files Browse the repository at this point in the history
  • Loading branch information
fleonce committed Jan 14, 2025
1 parent 6da2d4d commit 960c89c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions with_argparse/configure_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ def _call_dataclass(self, args: Sequence[Any], kwargs: Mapping[str, Any]):
if isinstance(field_type, str):
field_type = typing.cast(type, field_hints.get(field.name))

known_types = {type, Literal, GenericAlias}
if type(field_type) not in known_types and typing.get_origin(field_type) not in known_types:
raise ValueError(f"Cannot determine type of {field.name}, got {field_type} {type(field_type)}")
# known_types = {type, Literal, GenericAlias, UnionType}
# if type(field_type) not in known_types and typing.get_origin(field_type) not in known_types:
# raise ValueError(f"Cannot determine type of {field.name}, got {field_type} {type(field_type)}")
# raises on typing.Optional[typing.Literal['epsilon', 'v_prediction']]
self._setup_argument(
field.name,
field_type,
Expand Down

0 comments on commit 960c89c

Please sign in to comment.