summaryrefslogtreecommitdiffstats
path: root/Lib/dataclasses.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r--Lib/dataclasses.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 0c4b475..422a95c 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -152,6 +152,15 @@ __all__ = ['dataclass',
#
# See _hash_action (below) for a coded version of this table.
+# __match_args__
+#
+# | no | yes | <--- class has __match_args__ in __dict__?
+# +=======+=======+
+# | add | | <- the default
+# +=======+=======+
+# __match_args__ is always added unless the class already defines it. It is a
+# tuple of __init__ parameter names; non-init fields must be matched by keyword.
+
# Raised when an attempt is made to modify a frozen class.
class FrozenInstanceError(AttributeError): pass
@@ -1007,6 +1016,9 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen):
cls.__doc__ = (cls.__name__ +
str(inspect.signature(cls)).replace(' -> NoneType', ''))
+ if '__match_args__' not in cls.__dict__:
+ cls.__match_args__ = tuple(f.name for f in flds if f.init)
+
abc.update_abstractmethods(cls)
return cls