From 93f9e90b39c8e19ae8bccbf98659486735ded2c7 Mon Sep 17 00:00:00 2001 From: Alper Yoney Date: Thu, 19 Sep 2024 11:08:09 -0700 Subject: [PATCH] Address pyre errors in tests Summary: Address the pyre errors in tests, which appeared after enabling type hints for mutable types. Reviewed By: vitaut Differential Revision: D63032523 fbshipit-source-id: bbe07af4e7181b04e85576e0e3f7d6cecdf34f55 --- thrift/lib/python/test/enums.py | 1 + thrift/lib/python/test/maps.py | 3 +-- thrift/lib/python/test/sets.py | 3 +-- thrift/lib/python/test/structs.py | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/thrift/lib/python/test/enums.py b/thrift/lib/python/test/enums.py index 0f34651bc27..82faa12be99 100644 --- a/thrift/lib/python/test/enums.py +++ b/thrift/lib/python/test/enums.py @@ -447,6 +447,7 @@ def test_combo_repr(self) -> None: ) class EnumMetaTests(unittest.TestCase): def setUp(self) -> None: + # pyre-ignore[16]: has no attribute `test_types` self.Color: Type[Color] = self.test_types.Color self.Kind: Type[Kind] = self.test_types.Kind self.Perm: Type[Perm] = self.test_types.Perm diff --git a/thrift/lib/python/test/maps.py b/thrift/lib/python/test/maps.py index b6f6566c50f..6cf89a724eb 100644 --- a/thrift/lib/python/test/maps.py +++ b/thrift/lib/python/test/maps.py @@ -283,14 +283,13 @@ def test_contains_enum(self) -> None: # TODO: Collapse these two test cases into parameterized test above class MapMutablePythonTests(unittest.TestCase): - # pyre-ignore Color = mutable_containers_types.Color - # pyre-ignore Maps = mutable_containers_types.Maps # this test case documents behavior divergences from thrift-python @unittest.expectedFailure def test_contains_enum(self) -> None: + # pyre-ignore[6]: Fixme: type error to be addressed later cmap = self.Maps(colorMap={c: c for c in [self.Color.red, self.Color.blue]}) # TODO(T194526180): mutable thrift-python should not raise self.assertNotIn("str", cmap.colorMap) diff --git a/thrift/lib/python/test/sets.py b/thrift/lib/python/test/sets.py index a7bebb562b5..3759a9475cf 100644 --- a/thrift/lib/python/test/sets.py +++ b/thrift/lib/python/test/sets.py @@ -299,14 +299,13 @@ def test_contains_enum(self) -> None: # TODO: Collapse these two test cases into parameterized test above class SetMutablePythonTests(unittest.TestCase): - # pyre-ignore Color = mutable_containers_types.Color - # pyre-ignore Sets = mutable_containers_types.Sets # this test case documents behavior divergences from thrift-python @unittest.expectedFailure def test_contains_enum(self) -> None: + # pyre-ignore[6]: Fixme: type error to be addressed later cset = self.Sets(colorSet={self.Color.red, self.Color.blue}) # TODO(T194526180): mutable thrift-python should not raise self.assertNotIn("str", cset.colorSet) diff --git a/thrift/lib/python/test/structs.py b/thrift/lib/python/test/structs.py index 0801285930f..136dcab8d39 100644 --- a/thrift/lib/python/test/structs.py +++ b/thrift/lib/python/test/structs.py @@ -34,7 +34,6 @@ from parameterized import parameterized_class -# pyre-ignore[21]: Could not find a name from testing.thrift_mutable_types import __Reserved as DoubleUnderscoreReservedMutable from testing.thrift_types import ( @@ -98,10 +97,10 @@ def setUp(self) -> None: self.is_mutable_run: bool = self.test_types.__name__.endswith( "thrift_mutable_types" ) + # pyre-ignore[8]: Intentional for test self.DoubleUnderscoreReserved: Type[DoubleUnderscoreReserved] = ( DoubleUnderscoreReserved if not self.is_mutable_run - # pyre-ignore[16]: no attribute else DoubleUnderscoreReservedMutable ) # pyre-ignore[16]: has no attribute `serializer_module`