Unverified Commit 968ae57c authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Don't duplicate the elements in dir (#14023)

parent 84ad6af4
...@@ -2123,7 +2123,13 @@ class _LazyModule(ModuleType): ...@@ -2123,7 +2123,13 @@ class _LazyModule(ModuleType):
# Needed for autocompletion in an IDE # Needed for autocompletion in an IDE
def __dir__(self): def __dir__(self):
return super().__dir__() + self.__all__ result = super().__dir__()
# The elements of self.__all__ that are submodules may or may not be in the dir already, depending on whether
# they have been accessed or not. So we only add the elements of self.__all__ that are not already in the dir.
for attr in self.__all__:
if attr not in result:
result.append(attr)
return result
def __getattr__(self, name: str) -> Any: def __getattr__(self, name: str) -> Any:
if name in self._objects: if name in self._objects:
......
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