Skip to content

Commit fdcbd0e

Browse files
authored
Merge pull request numpy#27059 from arnaud-ma/attribute-error-no-name-suggestions
ENH: Disable name suggestions on some AttributeErrors
2 parents 22d34e9 + b61e079 commit fdcbd0e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

numpy/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def __getattr__(attr):
371371
return char
372372
elif attr == "array_api":
373373
raise AttributeError("`numpy.array_api` is not available from "
374-
"numpy 2.0 onwards")
374+
"numpy 2.0 onwards", name=None)
375375
elif attr == "core":
376376
import numpy.core as core
377377
return core
@@ -384,7 +384,7 @@ def __getattr__(attr):
384384
return distutils
385385
else:
386386
raise AttributeError("`numpy.distutils` is not available from "
387-
"Python 3.12 onwards")
387+
"Python 3.12 onwards", name=None)
388388

389389
if attr in __future_scalars__:
390390
# And future warnings for those that will change, but also give
@@ -394,12 +394,13 @@ def __getattr__(attr):
394394
"corresponding NumPy scalar.", FutureWarning, stacklevel=2)
395395

396396
if attr in __former_attrs__:
397-
raise AttributeError(__former_attrs__[attr])
397+
raise AttributeError(__former_attrs__[attr], name=None)
398398

399399
if attr in __expired_attributes__:
400400
raise AttributeError(
401401
f"`np.{attr}` was removed in the NumPy 2.0 release. "
402-
f"{__expired_attributes__[attr]}"
402+
f"{__expired_attributes__[attr]}",
403+
name=None
403404
)
404405

405406
if attr == "chararray":

numpy/lib/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def __getattr__(attr):
6767
raise AttributeError(
6868
"numpy.lib.emath was an alias for emath module that was removed "
6969
"in NumPy 2.0. Replace usages of numpy.lib.emath with "
70-
"numpy.emath."
70+
"numpy.emath.",
71+
name=None
7172
)
7273
elif attr in (
7374
"histograms", "type_check", "nanfunctions", "function_base",
@@ -77,12 +78,14 @@ def __getattr__(attr):
7778
raise AttributeError(
7879
f"numpy.lib.{attr} is now private. If you are using a public "
7980
"function, it should be available in the main numpy namespace, "
80-
"otherwise check the NumPy 2.0 migration guide."
81+
"otherwise check the NumPy 2.0 migration guide.",
82+
name=None
8183
)
8284
elif attr == "arrayterator":
8385
raise AttributeError(
8486
"numpy.lib.arrayterator submodule is now private. To access "
85-
"Arrayterator class use numpy.lib.Arrayterator."
87+
"Arrayterator class use numpy.lib.Arrayterator.",
88+
name=None
8689
)
8790
else:
8891
raise AttributeError("module {!r} has no attribute "

0 commit comments

Comments
 (0)