# https://bugs.python.org/issue33453 for details.
_MODULE_IDENTIFIER_RE = re.compile(r'^(?:\s*(\w+)\s*\.)?\s*(\w+)')
-class _InitVarMeta(type):
- def __getitem__(self, params):
- return InitVar(params)
-
-class InitVar(metaclass=_InitVarMeta):
+class InitVar:
__slots__ = ('type', )
def __init__(self, type):
def __repr__(self):
return f'dataclasses.InitVar[{self.type.__name__}]'
+ def __class_getitem__(cls, type):
+ return InitVar(type)
+
# Instances of Field are only ever created from within this module,
# and only from the field() function, although Field instances are