Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Remove builtins from __all__ #14881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@

# Make these accessible from numpy name-space
# but not imported in from numpy import *
# TODO[gh-6103]: Deprecate these
if sys.version_info[0] >= 3:
from builtins import bool, int, float, complex, object, str
unicode = str
Expand All @@ -168,14 +169,17 @@
# now that numpy modules are imported, can initialize limits
core.getlimits._register_known_types()

__all__.extend(['bool', 'int', 'float', 'complex', 'object', 'unicode',
'str'])
__all__.extend(['__version__', 'show_config'])
__all__.extend(core.__all__)
__all__.extend(_mat.__all__)
__all__.extend(lib.__all__)
__all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])

# These are added by `from .core import *` and `core.__all__`, but we
# overwrite them above with builtins we do _not_ want to export.
__all__.remove('long')
__all__.remove('unicode')

# Remove things that are in the numpy.lib but not in the numpy namespace
# Note that there is a test (numpy/tests/test_public_api.py:test_numpy_namespace)
# that prevents adding more things to the main namespace by accident.
Expand Down Expand Up @@ -216,7 +220,7 @@ def __getattr__(attr):
"{!r}".format(__name__, attr))

def __dir__():
return __all__ + ['Tester', 'testing']
return list(globals().keys()) + ['Tester', 'testing']

else:
# We don't actually use this ourselves anymore, but I'm not 100% sure that
Expand Down