summaryrefslogtreecommitdiffstats
path: root/Lib/dataclasses.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-06-01 08:00:15 (GMT)
committerGitHub <noreply@github.com>2019-06-01 08:00:15 (GMT)
commit2085bd0877e17ad4d98a4586d5eabb6faecbb190 (patch)
treec25b20d33ebf4d64a28abb8591f4ff7acf90614c /Lib/dataclasses.py
parent4a686504eb2bbf69adf78077458508a7ba131667 (diff)
downloadcpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.zip
cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.tar.gz
cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.tar.bz2
bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700)
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r--Lib/dataclasses.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 325b822..75113f1 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -962,10 +962,7 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen):
return cls
-# _cls should never be specified by keyword, so start it with an
-# underscore. The presence of _cls is used to detect if this
-# decorator is being called with parameters or not.
-def dataclass(_cls=None, *, init=True, repr=True, eq=True, order=False,
+def dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False,
unsafe_hash=False, frozen=False):
"""Returns the same class as was passed in, with dunder methods
added based on the fields defined in the class.
@@ -983,12 +980,12 @@ def dataclass(_cls=None, *, init=True, repr=True, eq=True, order=False,
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
# See if we're being called as @dataclass or @dataclass().
- if _cls is None:
+ if cls is None:
# We're called with parens.
return wrap
# We're called as @dataclass without parens.
- return wrap(_cls)
+ return wrap(cls)
def fields(class_or_instance):