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:
from typing import TypedDict, Unpack
class Args(TypedDict):
"""Arguments for the add function"""
a: int
"""The first number"""
b: int
"""The second number"""
def add(**args: Unpack[Args]) -> int:
"""Add two numbers together.
Args:
**args: The arguments for the function.
Returns:
The sum of the two numbers.
"""
return args["a"] + args["b"]
Renders as:
It would be nice if it were rendered as regular arguments instead, like:
They are basically above.
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.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too