Skip to content

Commit d10c2b9

Browse files
authored
dataclasses docs: consistent indentation (4 spaces) in examples (#98855)
1 parent 9bdec0a commit d10c2b9

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Doc/library/dataclasses.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Module contents
8181

8282
@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)
8383
class C:
84-
...
84+
...
8585

8686
The parameters to :func:`dataclass` are:
8787

@@ -482,10 +482,10 @@ Module contents
482482

483483
@dataclass
484484
class Point:
485-
x: float
486-
_: KW_ONLY
487-
y: float
488-
z: float
485+
x: float
486+
_: KW_ONLY
487+
y: float
488+
z: float
489489

490490
p = Point(0, y=1.5, z=2.0)
491491

@@ -773,24 +773,24 @@ default value have the following special behaviors:
773773
::
774774

775775
class IntConversionDescriptor:
776-
def __init__(self, *, default):
777-
self._default = default
776+
def __init__(self, *, default):
777+
self._default = default
778778

779-
def __set_name__(self, owner, name):
780-
self._name = "_" + name
779+
def __set_name__(self, owner, name):
780+
self._name = "_" + name
781781

782-
def __get__(self, obj, type):
783-
if obj is None:
784-
return self._default
782+
def __get__(self, obj, type):
783+
if obj is None:
784+
return self._default
785785

786-
return getattr(obj, self._name, self._default)
786+
return getattr(obj, self._name, self._default)
787787

788-
def __set__(self, obj, value):
789-
setattr(obj, self._name, int(value))
788+
def __set__(self, obj, value):
789+
setattr(obj, self._name, int(value))
790790

791791
@dataclass
792792
class InventoryItem:
793-
quantity_on_hand: IntConversionDescriptor = IntConversionDescriptor(default=100)
793+
quantity_on_hand: IntConversionDescriptor = IntConversionDescriptor(default=100)
794794

795795
i = InventoryItem()
796796
print(i.quantity_on_hand) # 100

0 commit comments

Comments
 (0)