
On Tue, Apr 5, 2022 at 9:51 PM Erik De Bonte <Erik.DeBonte@microsoft.com> wrote:
Maybe I'm overlooking something, but why couldn't the runtime definition be as simple as this?
def dataclass_transform(**kwds):
def decorator(thing):
thing .__dataclass_transform__ = kwds
return thing
return decorator
One advantage of explicitly listing the supported keyword args is that language servers can provide completion suggestions for them.
Agreed. So in the typeshed stubs this should have the full specification, and we should update this whenever we've agreed on a new keyword argument. But the runtime implementation (whether in stdlib (typing.py) or typing-extensions) doesn't need to do anything except setting the dunder attribute. By not making it check the arguments at runtime, users won't have to install a new version of typing-extensions, and there will (eventually) be less reason to import the typing-extensions version rather than the stdlib version. This is a general trend for runtime behavior of typing features -- we're removing runtime checks for things that type checkers already check, reducing the runtime cost and minimizing the need to update the runtime code. -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>