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
Is your feature request related to a problem? Please describe.
Not a problem, but when writing functions/classes with lots of options, and in particular when these options need to be forwarded down to a few levels, it is extremely convenient to use Unpack[TypeDict] as the type for keyword arguments and group all arguments in a class that can be reused.
For example:
fromtypingimportTypedDict, UnpackclassArgs(TypedDict):
"""Arguments for the add function"""a: int"""The first number"""b: int"""The second number"""defadd(**args: Unpack[Args]) ->int:
"""Add two numbers together. Args: **args: The arguments for the function. Returns: The sum of the two numbers. """returnargs["a"] +args["b"]
Renders as:
Describe the solution you'd like
It would be nice if it were rendered as regular arguments instead, like:
Describe alternatives you've considered
They are basically above.
Additional context
I know this might be tricky, specially considering cases using Args(TypeDict, total=False) or NotRequired as in this case some arguments could not be present at all, which is different from passing None for example. But maybe there is a low hanging fruit, and at least some limited support could be added.
Boost priority
Boost priority in our backlog through Polar.sh. Higher pledge, higher priority.
Minimum pledge by user/organization is $5, minimum amount for boost is $30.
No worries, it's not a duplicate. Support for Unpack must be implemented in Griffe, but here we also want an option to actually unpack the signature when rendering 🙂
Is your feature request related to a problem? Please describe.
Not a problem, but when writing functions/classes with lots of options, and in particular when these options need to be forwarded down to a few levels, it is extremely convenient to use
Unpack[TypeDict]
as the type for keyword arguments and group all arguments in a class that can be reused.For example:
Renders as:
Describe the solution you'd like
It would be nice if it were rendered as regular arguments instead, like:
Describe alternatives you've considered
They are basically above.
Additional context
I know this might be tricky, specially considering cases using
Args(TypeDict, total=False)
orNotRequired
as in this case some arguments could not be present at all, which is different from passingNone
for example. But maybe there is a low hanging fruit, and at least some limited support could be added.Boost priority
The text was updated successfully, but these errors were encountered: