So something around this topic has already been brought up in the past, but it was specific to namedtuples and was also 5 years ago. Given that typing as a first party construct is here to stay. I think it would be greatly beneficial if we could use automatic class initialization in function arguments (this is probably a poor way to state this).
from typing import NamedTuple from datetime import datetime class ArgumentGroup(NamedTuple): name:str date:datetime=datetime(year=1970,month=10,day=8) def greet(start:ArgumentGroup, how_many_times:int): pass greet(start=(name="Jeff"), how_many_times=10)
Basically instead of needing to construct a class ArgumentGroup the actually type can be inferred from the type hints and the constructor called. In order to prevent clashing with tuples it would be required that only keyword arguments are passed. Currently this code is just illegal. While this seems fairly useless inside of one file it has a great amount of utility for dealing imported functions. It would prevent the need for important dozens of classes and still allow code to use helper objects for argument grouping.
Ideally something like this could be reached via a __method__ so that arbitrary classes could implement it. It would really help with function parameter organization because it would dramatically reduce the burden of using tuples/classes to hold arguments. Particularly it creates a lot of wasted namespace to be importing all of them. TypedDict appears to have been trying to solve a similar issue but frankly I haven’t seen nor used it often. I imagine the scope of it was limited by it being in the pre type hints are first party era.