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
ContainerCLI.run() has several possible return types:
A Container when detach is True
An Iterable[Tuple[str, bytes]] when stream is True (side comment - this return type is missing from the docstring, which only mentions returning a Container or a str)
A str when both detach and stream are False
Currently, when I call run() with detach=True, although I know that it will return a Container, mypy complains about it, since nothing is telling it that the return is a Container and not one of the other possibilities.
It'd be nice if the run method were overloaded to type hint the correct return type based on the input parameters. In most cases, that wouldn't be too bad to overload, but since there are over 100 parameters to the function, having multiple overloads sounds like it'd be tedious to read and maintain.
A possible solution might be to leave the 100 kwargs on the overall signature, then use **kwargs on the overloaded signatures for all kwargs except detach and stream, which seemed like it kept mypy happy without requiring hundreds of duplicated lines of code, but it resulted in VSCode no longer providing tab completion options for the other kwargs. Not sure if the same would happen for other editors, but it wouldn't surprise me.
Any thoughts on how/if the return value could be typed which better takes into account the parameters? I'm happy to implement the changes if there's a good way of doing it! However I didn't want to just go ahead and submit a change that either introduces a ton of duplicated code, or breaks IDE tab completion.
The text was updated successfully, but these errors were encountered:
ContainerCLI.run()
has several possible return types:Container
whendetach
is TrueIterable[Tuple[str, bytes]]
whenstream
is True (side comment - this return type is missing from the docstring, which only mentions returning a Container or a str)str
when bothdetach
andstream
are FalseCurrently, when I call
run()
withdetach=True
, although I know that it will return aContainer
, mypy complains about it, since nothing is telling it that the return is aContainer
and not one of the other possibilities.It'd be nice if the run method were overloaded to type hint the correct return type based on the input parameters. In most cases, that wouldn't be too bad to overload, but since there are over 100 parameters to the function, having multiple overloads sounds like it'd be tedious to read and maintain.
A possible solution might be to leave the 100 kwargs on the overall signature, then use
**kwargs
on the overloaded signatures for all kwargs exceptdetach
andstream
, which seemed like it kept mypy happy without requiring hundreds of duplicated lines of code, but it resulted in VSCode no longer providing tab completion options for the other kwargs. Not sure if the same would happen for other editors, but it wouldn't surprise me.Any thoughts on how/if the return value could be typed which better takes into account the parameters? I'm happy to implement the changes if there's a good way of doing it! However I didn't want to just go ahead and submit a change that either introduces a ton of duplicated code, or breaks IDE tab completion.
The text was updated successfully, but these errors were encountered: