@@ -119,7 +119,7 @@ Type checkers supporting this PEP will recognize that the
119
119
c5 = CustomerModel(327 , " John Smith" , 0 )
120
120
121
121
Decorator function example
122
- ``````````````````````````
122
+ ''''''''''''''''''''''''''
123
123
124
124
.. code-block :: python
125
125
@@ -133,7 +133,6 @@ Decorator function example
133
133
cls .__eq__ = ...
134
134
cls .__ne__ = ...
135
135
return cls
136
-
137
136
138
137
# The ``create_model`` decorator can now be used to create new model
139
138
# classes, like this:
@@ -143,7 +142,7 @@ Decorator function example
143
142
name: str
144
143
145
144
Class example
146
- `````````````
145
+ '''''''''''''
147
146
148
147
.. code-block :: python
149
148
@@ -152,15 +151,14 @@ Class example
152
151
@typing.dataclass_transform ()
153
152
class ModelBase : ...
154
153
155
-
156
154
# The ``ModelBase`` class can now be used to create new model
157
155
# subclasses, like this:
158
156
class CustomerModel (ModelBase ):
159
157
id : int
160
158
name: str
161
159
162
160
Metaclass example
163
- `````````````````
161
+ '''''''''''''''''
164
162
165
163
.. code-block :: python
166
164
@@ -171,7 +169,6 @@ Metaclass example
171
169
172
170
class ModelBase (metaclass = ModelMeta ): ...
173
171
174
-
175
172
# The ``ModelBase`` class can now be used to create new model
176
173
# subclasses, like this:
177
174
class CustomerModel (ModelBase ):
@@ -189,7 +186,8 @@ these parameters accepts a bool argument, and it must be possible for
189
186
the bool value (``True `` or ``False ``) to be statically evaluated.
190
187
191
188
* ``eq ``. ``order ``, ``frozen ``, ``init `` and ``unsafe_hash `` are parameters
192
- supported in the stdlib dataclass, with meanings defined in :pep: `557 <557#id7 >`.
189
+ supported in the stdlib dataclass, with meanings defined in
190
+ :pep: `PEP 557 <557#id7 >`.
193
191
* ``hash `` is an alias for the ``unsafe_hash `` parameter.
194
192
* ``kw_only ``, ``match_args `` and ``slots `` are parameters supported
195
193
in the stdlib dataclass, first introduced in Python 3.10.
@@ -239,7 +237,7 @@ The following sections provide additional examples showing how these
239
237
parameters are used.
240
238
241
239
Decorator function example
242
- ``````````````````````````
240
+ ''''''''''''''''''''''''''
243
241
244
242
.. code-block :: python
245
243
@@ -254,7 +252,6 @@ Decorator function example
254
252
kw_only : bool = True ,
255
253
) -> Callable[[Type[_T]], Type[_T]]: ...
256
254
257
-
258
255
# Example of how this decorator would be used by code that imports
259
256
# from this library:
260
257
@create_model (frozen = True , kw_only = False )
@@ -263,7 +260,7 @@ Decorator function example
263
260
name: str
264
261
265
262
Class example
266
- `````````````
263
+ '''''''''''''
267
264
268
265
.. code-block :: python
269
266
@@ -281,7 +278,6 @@ Class example
281
278
):
282
279
...
283
280
284
-
285
281
# Example of how this class would be used by code that imports
286
282
# from this library:
287
283
class CustomerModel (
@@ -295,7 +291,7 @@ Class example
295
291
name: str
296
292
297
293
Metaclass example
298
- `````````````````
294
+ '''''''''''''''''
299
295
300
296
.. code-block :: python
301
297
@@ -319,7 +315,6 @@ Metaclass example
319
315
class ModelBase (metaclass = ModelMeta ):
320
316
...
321
317
322
-
323
318
# Example of how this class would be used by code that imports
324
319
# from this library:
325
320
class CustomerModel (
@@ -365,7 +360,7 @@ not required:
365
360
366
361
367
362
Field descriptor parameters
368
- ```````````````````````````
363
+ '''''''''''''''''''''''''''
369
364
370
365
Libraries that support dataclass-like semantics and support field
371
366
descriptor classes typically use common parameter names to construct
@@ -441,7 +436,6 @@ This example demonstrates the above:
441
436
init : bool = True ,
442
437
) -> Callable[[Type[_T]], Type[_T]]: ...
443
438
444
-
445
439
# Code that imports this library:
446
440
@create_model (init = False )
447
441
class CustomerModel :
@@ -701,14 +695,3 @@ Copyright
701
695
702
696
This document is placed in the public domain or under the
703
697
CC0-1.0-Universal license, whichever is more permissive.
704
-
705
-
706
-
707
- ..
708
- Local Variables:
709
- mode: indented-text
710
- indent-tabs-mode: nil
711
- sentence-end-double-space: t
712
- fill-column: 70
713
- coding: utf-8
714
- End:
0 commit comments