Commit e4d5f3f
committed
Use standard terminology for class pattern error message
When trying to use a class pattern to match on a non-class object, we
currently get the following error message:
Traceback (most recent call last):
File "/tmp/test.py", line 2, in <module>
case len():
~~~^^
TypeError: called match pattern must be a class
The terminology "called match pattern" here is a bit confusing. It's not
used anywhere else as far as I can tell, and for a beginner, it might
read like something is actually being called here.
The documentation consistently refers to these patterns as "class
patterns":
* https://docs.python.org/3/reference/compound_stmts.html#class-patterns
* https://peps.python.org/pep-0635/#class-patterns
* https://docs.python.org/3/library/ast.html#ast.MatchClass
* https://docs.python.org/3/reference/datamodel.html#customizing-positional-arguments-in-class-pattern-matching
I am therefore suggesting to change the message to "class pattern must
refer to a class".
See python#103576 for a PR that
previously changed this message (from "… must be a type" to "… must be a
class").1 parent b22ff1e commit e4d5f3f
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| |||
0 commit comments