Skip to content

Commit

Permalink
Remove some dead code.
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Nov 19, 2019
1 parent 99825f5 commit a2f91e6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
24 changes: 0 additions & 24 deletions monkeytype/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,30 +159,6 @@ def get_type(obj, max_typed_dict_size=None):
mappingproxy = type(range.__dict__)


def _get_union_type_str(t):
elem_types = t.__args__
if NoneType in elem_types:
# Optionals end up as Union[NoneType, ...], convert it back to
# Optional[...]
elem_type_strs = [
get_type_str(e) for e in elem_types if e is not NoneType]
return 'typing.Optional[' + ','.join(elem_type_strs) + ']'
return str(t)


def get_type_str(t):
mod = t.__module__
if mod == 'typing':
if is_union(t):
s = _get_union_type_str(t)
else:
s = str(t)
return s
elif mod == 'builtins':
return t.__qualname__
return mod + '.' + t.__qualname__


class TypeRewriter:
"""TypeRewriter provides a visitor for rewriting parts of types"""

Expand Down
17 changes: 0 additions & 17 deletions tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
RewriteConfigDict,
RewriteLargeUnion,
get_type,
get_type_str,
is_typed_dict,
shrink_types,
shrink_typed_dict_types,
Expand Down Expand Up @@ -265,22 +264,6 @@ def test_class_type(self):
assert get_type(Dummy) == Type[Dummy]


class TestGetTypeStr:
@pytest.mark.parametrize(
'typ, typ_str',
[
(str, 'str'),
(Dummy, 'tests.util.Dummy'),
(Optional[str], 'typing.Optional[str]'),
(Dict[str, Dummy], 'typing.Dict[str, tests.util.Dummy]'),
(TypedDict(DUMMY_TYPED_DICT_NAME, {'a': int, 'b': int}),
'tests.test_typing.' + DUMMY_TYPED_DICT_NAME),
],
)
def test_get_type_str(self, typ, typ_str):
assert get_type_str(typ) == typ_str


class Tuple:
"""A name conflict that is not generic."""
pass
Expand Down

0 comments on commit a2f91e6

Please sign in to comment.