Commit 2802fd93 authored by Jeremy Reizenstein's avatar Jeremy Reizenstein Committed by Facebook GitHub Bot
Browse files

fix Optional[List] in Configurable

Summary: Optional[not_a_type] was causing errors.

Reviewed By: davnov134

Differential Revision: D35355530

fbshipit-source-id: e9b52cfd6347ffae0fe688ef30523a4092ccf9fd
parent a999fc22
...@@ -746,7 +746,8 @@ def _get_type_to_process(type_) -> Optional[Tuple[Type, _ProcessType]]: ...@@ -746,7 +746,8 @@ def _get_type_to_process(type_) -> Optional[Tuple[Type, _ProcessType]]:
return return
underlying = args[0] if args[1] is type(None) else args[1] # noqa: E721 underlying = args[0] if args[1] is type(None) else args[1] # noqa: E721
if ( if (
issubclass(underlying, ReplaceableBase) isinstance(underlying, type)
and issubclass(underlying, ReplaceableBase)
and ReplaceableBase in underlying.__bases__ and ReplaceableBase in underlying.__bases__
): ):
return underlying, _ProcessType.OPTIONAL_REPLACEABLE return underlying, _ProcessType.OPTIONAL_REPLACEABLE
......
...@@ -109,6 +109,7 @@ class TestConfig(unittest.TestCase): ...@@ -109,6 +109,7 @@ class TestConfig(unittest.TestCase):
self.assertIsNone(gt(Optional[MainTest])) self.assertIsNone(gt(Optional[MainTest]))
self.assertIsNone(gt(Tuple[Fruit])) self.assertIsNone(gt(Tuple[Fruit]))
self.assertIsNone(gt(Tuple[Fruit, Animal])) self.assertIsNone(gt(Tuple[Fruit, Animal]))
self.assertIsNone(gt(Optional[List[int]]))
def test_simple_replacement(self): def test_simple_replacement(self):
struct = get_default_args(MainTest) struct = get_default_args(MainTest)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment