浏览代码

feat: implement itemgetter and typing placeholders #486

Steve 1 月之前
父节点
当前提交
37780ed884
共有 3 个文件被更改,包括 8 次插入0 次删除
  1. 6 0
      python/operator.py
  2. 2 0
      python/typing.py
  3. 0 0
      src/common/_generated.c

+ 6 - 0
python/operator.py

@@ -53,3 +53,9 @@ class attrgetter:
         self.attr = attr
     def __call__(self, obj):
         return getattr(obj, self.attr)
+
+class itemgetter:
+    def __init__(self, item):
+        self.item = item
+    def __call__(self, obj):
+        return obj[self.item]

+ 2 - 0
python/typing.py

@@ -57,5 +57,7 @@ assert_never = lambda x: x
 
 TypedDict = dict
 NotRequired = _PLACEHOLDER
+ReadOnly = _PLACEHOLDER
+Required = _PLACEHOLDER
 
 cast = lambda _, val: val

文件差异内容过多而无法显示
+ 0 - 0
src/common/_generated.c


部分文件因为文件数量过多而无法显示