-
Notifications
You must be signed in to change notification settings - Fork 263
Open
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations
Description
From python/typeshed#14558: Some classes (like re.Pattern
) are not instantiable at runtime:
>>> import re
>>> re.Pattern()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot create 're.Pattern' instances
Currently, there is no working way to mark classes as such. Ideas to mark classes:
- Annotate the return type of
__new__
asNoReturn
/Never
. - Set
__new__
toNone
(similar to how__hash__
works). - A new decorator.
dchevell and brianschubert
Metadata
Metadata
Assignees
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations