Created
August 18, 2020 14:14
-
-
Save takwas/0a13946c01cf20a9874342d4e56bd8c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Type, Union | |
class BaseType: | |
pass | |
class EvenType: | |
pass | |
class OddType: | |
pass | |
def func(num: Union[int, str], return_type_spec: Type[BaseType]) -> BaseType: | |
try: | |
if num % 2 == 0: | |
return EvenType() | |
return OddType() | |
except TypeError: | |
return BaseType() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment