summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-10-29 17:15:16 (GMT)
committerGitHub <noreply@github.com>2022-10-29 17:15:16 (GMT)
commite237bf6862eda71d0e7ac5ffba4626c234a7071a (patch)
tree0886c63996a3ce980e89b443620d18a3fc95c6bf
parent751da28febfb0d01ddb8a9b4cb3256386e5f6a81 (diff)
downloadcpython-e237bf6862eda71d0e7ac5ffba4626c234a7071a.zip
cpython-e237bf6862eda71d0e7ac5ffba4626c234a7071a.tar.gz
cpython-e237bf6862eda71d0e7ac5ffba4626c234a7071a.tar.bz2
dataclasses docs: consistent indentation (4 spaces) in examples (GH-98855)
(cherry picked from commit d10c2b97428bd07827f7bac4515d41ac08be7481) Co-authored-by: FC Stegerman <flx@obfusk.net>
-rw-r--r--Doc/library/dataclasses.rst32
1 files changed, 16 insertions, 16 deletions
diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index ab8df8b..c4895aa 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -81,7 +81,7 @@ Module contents
@dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)
class C:
- ...
+ ...
The parameters to :func:`dataclass` are:
@@ -482,10 +482,10 @@ Module contents
@dataclass
class Point:
- x: float
- _: KW_ONLY
- y: float
- z: float
+ x: float
+ _: KW_ONLY
+ y: float
+ z: float
p = Point(0, y=1.5, z=2.0)
@@ -773,24 +773,24 @@ default value have the following special behaviors:
::
class IntConversionDescriptor:
- def __init__(self, *, default):
- self._default = default
+ def __init__(self, *, default):
+ self._default = default
- def __set_name__(self, owner, name):
- self._name = "_" + name
+ def __set_name__(self, owner, name):
+ self._name = "_" + name
- def __get__(self, obj, type):
- if obj is None:
- return self._default
+ def __get__(self, obj, type):
+ if obj is None:
+ return self._default
- return getattr(obj, self._name, self._default)
+ return getattr(obj, self._name, self._default)
- def __set__(self, obj, value):
- setattr(obj, self._name, int(value))
+ def __set__(self, obj, value):
+ setattr(obj, self._name, int(value))
@dataclass
class InventoryItem:
- quantity_on_hand: IntConversionDescriptor = IntConversionDescriptor(default=100)
+ quantity_on_hand: IntConversionDescriptor = IntConversionDescriptor(default=100)
i = InventoryItem()
print(i.quantity_on_hand) # 100