Skip to content

PEP 681: Fix minor formatting and typographical issues #2382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 9 additions & 26 deletions pep-0681.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Type checkers supporting this PEP will recognize that the
c5 = CustomerModel(327, "John Smith", 0)

Decorator function example
``````````````````````````
''''''''''''''''''''''''''

.. code-block:: python

Expand All @@ -127,7 +127,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:
Expand All @@ -137,7 +136,7 @@ Decorator function example
name: str

Class example
`````````````
'''''''''''''

.. code-block:: python

Expand All @@ -146,15 +145,14 @@ Class example
@typing.dataclass_transform()
class ModelBase: ...


# The ``ModelBase`` class can now be used to create new model
# subclasses, like this:
class CustomerModel(ModelBase):
id: int
name: str

Metaclass example
`````````````````
'''''''''''''''''

.. code-block:: python

Expand All @@ -165,7 +163,6 @@ Metaclass example

class ModelBase(metaclass=ModelMeta): ...


# The ``ModelBase`` class can now be used to create new model
# subclasses, like this:
class CustomerModel(ModelBase):
Expand All @@ -183,7 +180,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`` and ``slots`` are parameters supported in the stdlib dataclass,
first introduced in Python 3.10.
Expand Down Expand Up @@ -233,7 +231,7 @@ The following sections provide additional examples showing how these
parameters are used.

Decorator function example
``````````````````````````
''''''''''''''''''''''''''

.. code-block:: python

Expand All @@ -248,7 +246,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)
Expand All @@ -257,7 +254,7 @@ Decorator function example
name: str

Class example
`````````````
'''''''''''''

.. code-block:: python

Expand All @@ -275,7 +272,6 @@ Class example
):
...


# Example of how this class would be used by code that imports
# from this library:
class CustomerModel(
Expand All @@ -289,7 +285,7 @@ Class example
name: str

Metaclass example
`````````````````
'''''''''''''''''

.. code-block:: python

Expand All @@ -313,7 +309,6 @@ Metaclass example
class ModelBase(metaclass=ModelMeta):
...


# Example of how this class would be used by code that imports
# from this library:
class CustomerModel(
Expand Down Expand Up @@ -359,7 +354,7 @@ not required:


Field descriptor parameters
```````````````````````````
'''''''''''''''''''''''''''

Libraries that support dataclass-like semantics and support field
descriptor classes typically use common parameter names to construct
Expand Down Expand Up @@ -424,7 +419,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:
Expand Down Expand Up @@ -721,14 +715,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: