Replies: 1 comment 1 reply
-
There's no mechanism in the current Python type system to auto-generate this. If it's something you need to do often for many functions, you could write a small script to generate it. You could also change the constructor to accept the TypedDict as a parameter directly. AConfig(TypedDict):
x: int
y: int
class A:
def __init__(self, config: AConfig):
self.x = config["x"]
self.y = config["y"]
Class Container:
def __init__(a_config: AConfig):
# do some logic like saving configs and etc
self.a = A(a_config) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi.
Normally we define our config objects similar to this:
Is there anyway to auto generate
AConfig
fromA.__init__
signature?Beta Was this translation helpful? Give feedback.
All reactions