ReReland Fix public binding check for modules with __all__

Pull Request resolved: https://github.com/pytorch/pytorch/pull/76045

Approved by: https://github.com/samdow
This commit is contained in:
Alban Desmaison 2022-04-19 11:49:24 -04:00 committed by PyTorch MergeBot
parent 8c37a056df
commit d2517a43db
2 changed files with 438 additions and 455 deletions

File diff suppressed because it is too large Load Diff

View File

@ -325,11 +325,11 @@ class TestPublicBindings(TestCase):
if is_public != looks_public:
add_to_failure_list_if_not_in_allow_dict(modname, elem, elem_module)
if hasattr(modname, '__all__'):
if hasattr(mod, '__all__'):
public_api = mod.__all__
all_api = dir(modname)
all_api = dir(mod)
for elem in all_api:
looks_public_or_not(elem, modname, is_public=elem in public_api)
looks_public_or_not(elem, modname, mod, is_public=elem in public_api)
else:
all_api = dir(mod)