diff --git a/third-party/thrift/src/thrift/lib/python/any/serializer.pyi b/third-party/thrift/src/thrift/lib/python/any/serializer.pyi index 12e36d9fc7b51..5224a9feacb00 100644 --- a/third-party/thrift/src/thrift/lib/python/any/serializer.pyi +++ b/third-party/thrift/src/thrift/lib/python/any/serializer.pyi @@ -41,6 +41,7 @@ def serialize_primitive( ) -> IOBuf: ... def deserialize_primitive( cls: typing.Type[TPrimitive], + # pyre-fixme[24]: Generic type `memoryview` expects 1 type parameter. buf: typing.Union[bytes, bytearray, IOBuf, memoryview], protocol: Protocol = ..., thrift_type: typing.Optional[Type] = ..., @@ -51,6 +52,7 @@ def serialize_list( ) -> IOBuf: ... def deserialize_list( elem_cls: typing.Type[TSerializable], + # pyre-fixme[24]: Generic type `memoryview` expects 1 type parameter. buf: typing.Union[bytes, bytearray, IOBuf, memoryview], protocol: Protocol = ..., ) -> typing.Sequence[TSerializable]: ... @@ -60,6 +62,7 @@ def serialize_set( ) -> IOBuf: ... def deserialize_set( elem_cls: typing.Type[TSerializable], + # pyre-fixme[24]: Generic type `memoryview` expects 1 type parameter. buf: typing.Union[bytes, bytearray, IOBuf, memoryview], protocol: Protocol = ..., ) -> typing.AbstractSet[TSerializable]: ... @@ -70,6 +73,7 @@ def serialize_map( def deserialize_map( key_cls: typing.Type[TKey], value_cls: typing.Type[TValue], + # pyre-fixme[24]: Generic type `memoryview` expects 1 type parameter. buf: typing.Union[bytes, bytearray, IOBuf, memoryview], protocol: Protocol = ..., ) -> typing.Mapping[TKey, TValue]: ... diff --git a/third-party/thrift/src/thrift/lib/python/common.pyi b/third-party/thrift/src/thrift/lib/python/common.pyi index 3dccfb249662f..6c54717b10325 100644 --- a/third-party/thrift/src/thrift/lib/python/common.pyi +++ b/third-party/thrift/src/thrift/lib/python/common.pyi @@ -34,6 +34,8 @@ class Priority(Enum): class Headers(Mapping[str, str]): def __repr__(self) -> str: ... def __len__(self) -> int: ... + # pyre-fixme[14]: `__contains__` overrides method defined in `Mapping` + # inconsistently. def __contains__(self, o: object) -> bool: ... def __getitem__(self, key: str) -> str: ... def __iter__(self) -> Iterator[str]: ... diff --git a/third-party/thrift/src/thrift/lib/python/mutable_containers.pyi b/third-party/thrift/src/thrift/lib/python/mutable_containers.pyi index 46d8a894bc11a..93ff5a548e435 100644 --- a/third-party/thrift/src/thrift/lib/python/mutable_containers.pyi +++ b/third-party/thrift/src/thrift/lib/python/mutable_containers.pyi @@ -49,6 +49,7 @@ class MutableList(MutableSequence[T]): @overload def __getitem__(self, index: int) -> T: ... @overload + # pyre-fixme[24]: Generic type `slice` expects 3 type parameters. def __getitem__(self, index: slice) -> MutableList[T]: ... @overload def __setitem__(self, index: int, value: T) -> None: ... @@ -71,6 +72,7 @@ class MutableList(MutableSequence[T]): @overload def __delitem__(self, index: int) -> None: ... @overload + # pyre-fixme[24]: Generic type `slice` expects 3 type parameters. def __delitem__(self, index: slice) -> None: ... @overload def insert(self, index: int, value: T) -> None: ... @@ -200,6 +202,7 @@ class MutableMap(Generic[K, V]): val_typeinfo: object, map_data: Mapping[object, object], ) -> None: ... + def __len__(self) -> int: ... def __getitem__(self, key: K) -> V: ... def __iter__(self) -> ValueIterator[K]: ... def get(self, key: K, default: Optional[V] = None) -> V: ... @@ -243,10 +246,12 @@ class MutableMap(Generic[K, V]): def setdefault(self, key: object, default: typing.Optional[object] = None) -> V: ... class MapKeysView(Generic[K]): + def __len__(self) -> int: ... def __contains__(self, key: object) -> bool: ... def __iter__(self) -> ValueIterator[K]: ... class MapItemsView(Generic[K, V]): + def __len__(self) -> int: ... def __contains__(self, key: K) -> bool: ... def __iter__(self) -> MapItemIterator[tuple[K, V]]: ... @@ -255,4 +260,5 @@ class MapItemIterator(Iterator[T]): def __iter__(self) -> MapItemIterator[T]: ... class MapValuesView(Generic[V]): + def __len__(self) -> int: ... def __iter__(self) -> ValueIterator[V]: ... diff --git a/third-party/thrift/src/thrift/lib/python/mutable_serializer.pyi b/third-party/thrift/src/thrift/lib/python/mutable_serializer.pyi index 7aaa585f9d363..1640f5de6a0ae 100644 --- a/third-party/thrift/src/thrift/lib/python/mutable_serializer.pyi +++ b/third-party/thrift/src/thrift/lib/python/mutable_serializer.pyi @@ -29,11 +29,13 @@ def serialize_iobuf(strct: sT, protocol: Protocol = Protocol.COMPACT) -> IOBuf: def serialize(struct: sT, protocol: Protocol = Protocol.COMPACT) -> bytes: ... def deserialize_with_length( klass: typing.Type[sT], + # pyre-fixme[24]: Generic type `memoryview` expects 1 type parameter. buf: typing.Union[bytes, bytearray, IOBuf, memoryview], protocol: Protocol = Protocol.COMPACT, ) -> typing.Tuple[sT, int]: ... def deserialize( klass: typing.Type[sT], + # pyre-fixme[24]: Generic type `memoryview` expects 1 type parameter. buf: typing.Union[bytes, bytearray, IOBuf, memoryview], protocol: Protocol = Protocol.COMPACT, ) -> sT: ... diff --git a/third-party/thrift/src/thrift/lib/python/serializer.pyi b/third-party/thrift/src/thrift/lib/python/serializer.pyi index fbd8e6604db14..4f938d9992ce0 100644 --- a/third-party/thrift/src/thrift/lib/python/serializer.pyi +++ b/third-party/thrift/src/thrift/lib/python/serializer.pyi @@ -30,6 +30,7 @@ def serialize_iobuf(strct: sT, protocol: Protocol = Protocol.COMPACT) -> IOBuf: def serialize(struct: sT, protocol: Protocol = Protocol.COMPACT) -> bytes: ... def deserialize_with_length( klass: typing.Type[sT], + # pyre-fixme[24]: Generic type `memoryview` expects 1 type parameter. buf: typing.Union[bytes, bytearray, IOBuf, memoryview], protocol: Protocol = Protocol.COMPACT, *, @@ -37,6 +38,7 @@ def deserialize_with_length( ) -> typing.Tuple[sT, int]: ... def deserialize( klass: typing.Type[sT], + # pyre-fixme[24]: Generic type `memoryview` expects 1 type parameter. buf: typing.Union[bytes, bytearray, IOBuf, memoryview], protocol: Protocol = Protocol.COMPACT, *, diff --git a/third-party/thrift/src/thrift/lib/python/test/maps.py b/third-party/thrift/src/thrift/lib/python/test/maps.py index 3f3ef16ab1c83..6b183c21803a1 100644 --- a/third-party/thrift/src/thrift/lib/python/test/maps.py +++ b/third-party/thrift/src/thrift/lib/python/test/maps.py @@ -145,14 +145,18 @@ def test_getitem(self) -> None: self.assertEqual(x["test"], "value") self.assertEqual(x[MyStringEnum.test], "value") with self.assertRaises(KeyError): + # pyre-ignore[6]: Intentional for test x[5] with self.assertRaises(KeyError): + # pyre-ignore[6]: Intentional for test x[x] def test_get(self) -> None: x = self.StrStrMap({"test": "value"}) self.assertEqual(x.get("test"), "value") + # pyre-ignore[6]: Intentional for test self.assertIs(x.get(5), None) + # pyre-ignore[6]: Intentional for test self.assertIs(x.get(x), None) def test_contains(self) -> None: @@ -313,11 +317,16 @@ def test_contains_enum(self) -> None: self.assertIn(1, cmap.colorMap) self.assertNotIn(2, cmap.colorMap) # gross + # pyre-ignore[6]: Intentional for test self.assertEqual(cmap.colorMap[0], self.Color.red) + # pyre-ignore[6]: Intentional for test self.assertEqual(cmap.colorMap[1], self.Color.blue) + # pyre-ignore[6]: Intentional for test self.assertEqual(cmap.colorMap.get(0), self.Color.red) + # pyre-ignore[6]: Intentional for test self.assertEqual(cmap.colorMap.get(1), self.Color.blue) + # pyre-ignore[6]: Intentional for test self.assertEqual(cmap.colorMap.get(2), None)