-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
According to the documentation, the way to make positional arguments in TAP is to define a configure method and call self.add_argument("argument_name"). However, that does not work with a pydantic model (using either tapify or to_tap_class) as the TAP class is auto-generated without the option to customise.
Here are a few things I have tried:
- Add
configuremethod to the pydantic model:
class MyModel(pydantic.BaseModel):
foo: str
def configure(self):
assert False # this is never called
tapify(MyModel) # the following arguments are required: foo- Call
add_argumentmanually:
class MyModel(pydantic.BaseModel):
foo: str
parser = to_tap_class(MyModel)()
parser.add_argument("foo") # Raises "ValueError: add_argument cannot be called after initialization."- Subclass workaround
class MyModel(pydantic.BaseModel):
foo: str
class MyModelTap(to_tap_class(MyModel)): # type: ignore
def configure(self):
self.add_argument("foo")
parser = MyModelTap()
parser.parse_args(argv) # this does work, but breaks typingPlease can support for this use-case be added to the library?
Metadata
Metadata
Assignees
Labels
No labels