Skip to content

Commit

Permalink
Address pyre errors in tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yoney authored and facebook-github-bot committed Sep 19, 2024
1 parent ac5e2ba commit 6345291
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions third-party/thrift/src/thrift/lib/python/test/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions third-party/thrift/src/thrift/lib/python/test/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions third-party/thrift/src/thrift/lib/python/test/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions third-party/thrift/src/thrift/lib/python/test/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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`
Expand Down

0 comments on commit 6345291

Please sign in to comment.