PEP 653: Make it clearer that MATCH_DEFAULT is the default. (#1823)

This commit is contained in:
Mark Shannon 2021-02-19 18:55:47 +00:00 committed by GitHub
parent 89183f61d1
commit c8f7f9cd7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -119,7 +119,8 @@ Additions to the object model
-----------------------------
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::
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
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
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,
rather than the ``__match_args__`` method, and allows classes more control over how
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.