diff --git a/pep-0681.rst b/pep-0681.rst index 3f0ba2ab4..4295055ae 100644 --- a/pep-0681.rst +++ b/pep-0681.rst @@ -119,7 +119,7 @@ Type checkers supporting this PEP will recognize that the c5 = CustomerModel(327, "John Smith", 0) Decorator function example -`````````````````````````` +'''''''''''''''''''''''''' .. code-block:: python @@ -133,7 +133,6 @@ Decorator function example cls.__eq__ = ... cls.__ne__ = ... return cls - # The ``create_model`` decorator can now be used to create new model # classes, like this: @@ -143,7 +142,7 @@ Decorator function example name: str Class example -````````````` +''''''''''''' .. code-block:: python @@ -152,7 +151,6 @@ Class example @typing.dataclass_transform() class ModelBase: ... - # The ``ModelBase`` class can now be used to create new model # subclasses, like this: class CustomerModel(ModelBase): @@ -160,7 +158,7 @@ Class example name: str Metaclass example -````````````````` +''''''''''''''''' .. code-block:: python @@ -171,7 +169,6 @@ Metaclass example class ModelBase(metaclass=ModelMeta): ... - # The ``ModelBase`` class can now be used to create new model # subclasses, like this: class CustomerModel(ModelBase): @@ -189,7 +186,8 @@ these parameters accepts a bool argument, and it must be possible for the bool value (``True`` or ``False``) to be statically evaluated. * ``eq``. ``order``, ``frozen``, ``init`` and ``unsafe_hash`` are parameters - supported in the stdlib dataclass, with meanings defined in :pep:`557 <557#id7>`. + supported in the stdlib dataclass, with meanings defined in + :pep:`PEP 557 <557#id7>`. * ``hash`` is an alias for the ``unsafe_hash`` parameter. * ``kw_only``, ``match_args`` and ``slots`` are parameters supported in the stdlib dataclass, first introduced in Python 3.10. @@ -239,7 +237,7 @@ The following sections provide additional examples showing how these parameters are used. Decorator function example -`````````````````````````` +'''''''''''''''''''''''''' .. code-block:: python @@ -254,7 +252,6 @@ Decorator function example kw_only: bool = True, ) -> Callable[[Type[_T]], Type[_T]]: ... - # Example of how this decorator would be used by code that imports # from this library: @create_model(frozen=True, kw_only=False) @@ -263,7 +260,7 @@ Decorator function example name: str Class example -````````````` +''''''''''''' .. code-block:: python @@ -281,7 +278,6 @@ Class example ): ... - # Example of how this class would be used by code that imports # from this library: class CustomerModel( @@ -295,7 +291,7 @@ Class example name: str Metaclass example -````````````````` +''''''''''''''''' .. code-block:: python @@ -319,7 +315,6 @@ Metaclass example class ModelBase(metaclass=ModelMeta): ... - # Example of how this class would be used by code that imports # from this library: class CustomerModel( @@ -365,7 +360,7 @@ not required: Field descriptor parameters -``````````````````````````` +''''''''''''''''''''''''''' Libraries that support dataclass-like semantics and support field descriptor classes typically use common parameter names to construct @@ -441,7 +436,6 @@ This example demonstrates the above: init: bool = True, ) -> Callable[[Type[_T]], Type[_T]]: ... - # Code that imports this library: @create_model(init=False) class CustomerModel: @@ -701,14 +695,3 @@ Copyright This document is placed in the public domain or under the CC0-1.0-Universal license, whichever is more permissive. - - - -.. - Local Variables: - mode: indented-text - indent-tabs-mode: nil - sentence-end-double-space: t - fill-column: 70 - coding: utf-8 - End: