Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Confusing error message when attempting to pass a newtype as a match pattern #100530

Closed
Assignees
brandtbucher
Labels
@not-my-profile

Description

@not-my-profile
fromtypingimportNewTypeT=NewType('T',str)match'test':caseT(): ...

fails with:

Traceback (most recent call last):  File "/tmp/foo.py", line 6, in <module>    case T(): ...         ^^^TypeError: called match pattern must be a type

The error message is confusing becauseT is a type. The error message should probably sayclass instead oftype, sinceas per the specification it's a class pattern.

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp