Merge pull request #16103 from jakevdp:deprecation-stacklevel

PiperOrigin-RevId: 534616543
This commit is contained in:
jax authors 2023-05-23 17:32:17 -07:00
commit 2d525b815d

View File

@ -48,7 +48,7 @@ def deprecation_getattr(module, deprecations):
message, fn = deprecations[name]
if fn is None:
raise AttributeError(message)
warnings.warn(message, DeprecationWarning)
warnings.warn(message, DeprecationWarning, stacklevel=2)
return fn
raise AttributeError(f"module {module!r} has no attribute {name!r}")