Fix some minor typos.
This commit is contained in:
parent
4c8bf1956e
commit
6d4f10e59d
30
pep-0557.rst
30
pep-0557.rst
|
@ -143,12 +143,12 @@ The ``dataclass`` decorator examines the class to find ``field``'s. A
|
||||||
type annotation. With a single exception described below, none of the
|
type annotation. With a single exception described below, none of the
|
||||||
Data Class machinery examines the type specified in the annotation.
|
Data Class machinery examines the type specified in the annotation.
|
||||||
|
|
||||||
Note that ``__annotations__`` is guaranateed to be an ordered mapping,
|
Note that ``__annotations__`` is guaranteed to be an ordered mapping,
|
||||||
in class declaration order. The order of the fields in all of the
|
in class declaration order. The order of the fields in all of the
|
||||||
generated methods is the order in which they appear in the class.
|
generated methods is the order in which they appear in the class.
|
||||||
|
|
||||||
The ``dataclass`` decorator is typically used with no parameters and
|
The ``dataclass`` decorator is typically used with no parameters and
|
||||||
no parenthesis. However, it also supports the following logical
|
no parentheses. However, it also supports the following logical
|
||||||
signature::
|
signature::
|
||||||
|
|
||||||
def dataclass(*, init=True, repr=True, hash=None, cmp=True, frozen=False)
|
def dataclass(*, init=True, repr=True, hash=None, cmp=True, frozen=False)
|
||||||
|
@ -197,14 +197,14 @@ The parameters to ``dataclass`` are:
|
||||||
superclass is object, this means it will fall back to id-based
|
superclass is object, this means it will fall back to id-based
|
||||||
hashing).
|
hashing).
|
||||||
|
|
||||||
Although not recommended, you force Data Classes to create a
|
Although not recommended, you can force Data Classes to create a
|
||||||
``__hash__`` method ``hash=True``. This might be the case if your
|
``__hash__`` method with ``hash=True``. This might be the case if your
|
||||||
class is logically immutable but can none the less be mutated. This
|
class is logically immutable but can nonetheless be mutated. This
|
||||||
is a specialized use case and should be considered carefully.
|
is a specialized use case and should be considered carefully.
|
||||||
|
|
||||||
See the Python documentation [#]_ for more information.
|
See the Python documentation [#]_ for more information.
|
||||||
|
|
||||||
- ``frozen``: If true, assigning to fields will generate an exception.
|
- ``frozen``: If True, assigning to fields will generate an exception.
|
||||||
This emulates read-only frozen instances. See the discussion below.
|
This emulates read-only frozen instances. See the discussion below.
|
||||||
|
|
||||||
``field``'s may optionally specify a default value, using normal
|
``field``'s may optionally specify a default value, using normal
|
||||||
|
@ -235,22 +235,22 @@ The parameters to ``field()`` are:
|
||||||
field. This is needed because the ``field`` call itself replaces
|
field. This is needed because the ``field`` call itself replaces
|
||||||
the normal position of the default value.
|
the normal position of the default value.
|
||||||
|
|
||||||
- ``default_factory``: If provided, a zero-argument callable that will
|
- ``default_factory``: If provided, it must be a zero-argument
|
||||||
be called when a default value is needed for this field. Among
|
callable that will be called when a default value is needed for this
|
||||||
other purposes, this can be used to specify fields with mutable
|
field. Among other purposes, this can be used to specify fields
|
||||||
default values, discussed below. It is an error to specify both
|
with mutable default values, as discussed below. It is an error to
|
||||||
``default`` and ``default_factory``.
|
specify both ``default`` and ``default_factory``.
|
||||||
|
|
||||||
- ``init``: If true, this field is included as a parameter to the
|
- ``init``: If True, this field is included as a parameter to the
|
||||||
generated ``__init__`` function.
|
generated ``__init__`` function.
|
||||||
|
|
||||||
- ``repr``: If true, this field is included in the string returned by
|
- ``repr``: If True, this field is included in the string returned by
|
||||||
the generated ``__repr__`` function.
|
the generated ``__repr__`` function.
|
||||||
|
|
||||||
- ``cmp``: If true, this field is included in the generated comparison
|
- ``cmp``: If True, this field is included in the generated comparison
|
||||||
methods (``__eq__`` et al).
|
methods (``__eq__`` et al).
|
||||||
|
|
||||||
- ``hash``: This can be a bool or ``None``. If true, this field is
|
- ``hash``: This can be a bool or ``None``. If True, this field is
|
||||||
included in the generated ``__hash__`` method. If ``None`` (the
|
included in the generated ``__hash__`` method. If ``None`` (the
|
||||||
default), use the value of ``cmp``: this would normally be the
|
default), use the value of ``cmp``: this would normally be the
|
||||||
expected behavior. A field needs to be considered in the hash if
|
expected behavior. A field needs to be considered in the hash if
|
||||||
|
|
Loading…
Reference in New Issue