PEP 653: Make it clearer that MATCH_DEFAULT is the default. (#1823)
This commit is contained in:
parent
89183f61d1
commit
c8f7f9cd7c
|
@ -119,7 +119,8 @@ Additions to the object model
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
A ``__match_kind__`` attribute will be added to ``object``.
|
A ``__match_kind__`` attribute will be added to ``object``.
|
||||||
It should be overridden by classes that want to match class, mapping or sequence patterns.
|
It should be overridden by classes that want to match mapping or sequence patterns,
|
||||||
|
or want change the default behavior when matching class patterns.
|
||||||
It must be an integer and should be exactly one of these::
|
It must be an integer and should be exactly one of these::
|
||||||
|
|
||||||
0
|
0
|
||||||
|
@ -138,6 +139,8 @@ bitwise ``or``\ ed with exactly one of these::
|
||||||
Symbolic constants will be provided both for Python and C, and once defined they will
|
Symbolic constants will be provided both for Python and C, and once defined they will
|
||||||
never be changed.
|
never be changed.
|
||||||
|
|
||||||
|
Classes inheriting from ``object`` will inherit ``__match_kind__ = MATCH_DEFAULT``.
|
||||||
|
|
||||||
Classes which define ``__match_kind__ & MATCH_CLASS`` to be non-zero must
|
Classes which define ``__match_kind__ & MATCH_CLASS`` to be non-zero must
|
||||||
implement one additional special attribute, and one special method:
|
implement one additional special attribute, and one special method:
|
||||||
|
|
||||||
|
@ -612,6 +615,8 @@ The changes to the semantics can be summarized as:
|
||||||
* Class matching is via the ``__attributes__`` attribute and ``__deconstruct__`` method,
|
* Class matching is via the ``__attributes__`` attribute and ``__deconstruct__`` method,
|
||||||
rather than the ``__match_args__`` method, and allows classes more control over how
|
rather than the ``__match_args__`` method, and allows classes more control over how
|
||||||
they are deconstructed.
|
they are deconstructed.
|
||||||
|
* The default behavior when matching a class pattern with keyword patterns is changed.
|
||||||
|
Only the instance dictionary is used. This is to avoid unintended capture of bound-methods.
|
||||||
|
|
||||||
There are no changes to syntax.
|
There are no changes to syntax.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue