Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
A similar issue to#96151. ericvsmith mentioned this is worth opening an issue for in#98143 (comment)
dataclasses uses variables with single underscore names as part of its implementation. This can cause interesting errors, for example:
fromdataclassesimportdataclass,field@dataclassclassX:x:int=field(default_factory=lambda:111)_dflt_x:int=field(default_factory=lambda:222)X()# TypeError: '_HAS_DEFAULT_FACTORY_CLASS' object is not callable
The fix is simple: prefix all of these things with__dataclass_, to make name collisions more obviously the user's fault. We already do this for e.g.__dataclass_self__ in the implementation.