def test_nested_class(self): assert get_imports_for_annotation(Parent.Child) == { Parent.__module__: {'Parent'} }
def test_container_types(self, anno, expected): """We need to descend into container types""" assert get_imports_for_annotation(anno) == expected
def test_special_case_types(self, anno, expected): """Any and Union do not have module/qualname and need to be treated specially""" assert get_imports_for_annotation(anno) == expected
def test_user_defined_class(self): assert get_imports_for_annotation(Dummy) == {'tests.util': {'Dummy'}}
def test_no_imports(self, anno): """We shouldn't import any builtins, non-types, or empty annos""" assert get_imports_for_annotation(anno) == {}