blueloveTH 2 years ago
parent
commit
2b031e61a2
2 changed files with 6 additions and 1 deletions
  1. 1 0
      python/builtins.py
  2. 5 1
      python/typing.py

+ 1 - 0
python/builtins.py

@@ -222,6 +222,7 @@ tuple.__ge__ = __f
 list.__ge__ = __f
 
 type.__repr__ = lambda self: "<class '" + self.__name__ + "'>"
+type.__getitem__ = lambda self, T: self     # for generics
 
 def help(obj):
     if hasattr(obj, '__func__'):

+ 5 - 1
python/typing.py

@@ -20,4 +20,8 @@ Callable = _PLACEHOLDER
 Type = _PLACEHOLDER
 
 TypeVar = _PLACEHOLDER
-Self = _PLACEHOLDER
+Self = _PLACEHOLDER
+
+class Generic:
+    def __getitem__(self, T):
+        return object