You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We hit another issue with some nested configs we're using -- basically something is going awry (I think) due to a type Union.
Here's a MWE:
import dataclasses
import dcargs
from typing import Tuple, Union
@dataclasses.dataclass(frozen=True)
class Subtype:
data: int = 1
@dataclasses.dataclass(frozen=True)
class TypeA:
subtype: Subtype = Subtype(1)
@dataclasses.dataclass(frozen=True)
class TypeB:
subtype: Subtype = Subtype(2)
@dataclasses.dataclass(frozen=True)
class Wrapper:
supertype: Union[TypeA, TypeB] = TypeA()
if __name__ == "__main__":
wrapper = dcargs.cli(Wrapper) # errors when running with supertype:type-a
print(wrapper)
If you put this in a module subparsers.py and run $ python subparsers.py, everything works; if you run $ python subparsers.py supertype:type-a, it throws the following error:
File "/opt/conda/lib/python3.7/site-packages/dcargs/_cli.py", line 272, in _cli_impl
avoid_subparsers=avoid_subparsers,
File "/opt/conda/lib/python3.7/site-packages/dcargs/_calling.py", line 169, in call_from_args
avoid_subparsers=avoid_subparsers,
File "/opt/conda/lib/python3.7/site-packages/dcargs/_calling.py", line 117, in call_from_args
assert len(parser_definition.subparsers_from_name) > 0
AssertionError
Thanks again for the great package + sorry to raise obscure issues! No problem if this isn't high-priority.
The text was updated successfully, but these errors were encountered:
Hi Brent,
We hit another issue with some nested configs we're using -- basically something is going awry (I think) due to a type Union.
Here's a MWE:
If you put this in a module
subparsers.py
and run$ python subparsers.py
, everything works; if you run$ python subparsers.py supertype:type-a
, it throws the following error:Thanks again for the great package + sorry to raise obscure issues! No problem if this isn't high-priority.
The text was updated successfully, but these errors were encountered: