diff --git a/IPython/core/oinspect.py b/IPython/core/oinspect.py index 0b8b2b8..ef6a0d0 100644 --- a/IPython/core/oinspect.py +++ b/IPython/core/oinspect.py @@ -69,6 +69,23 @@ class OInfo: parent: Any obj: Any + def get(self, field): + """Get a field from the object for backward compatibility with before 8.12 + + see https://github.com/h5py/h5py/issues/2253 + """ + # We need to deprecate this at some point, but the warning will show in completion. + # Let's comment this for now and uncomment end of 2023 ish + # warnings.warn( + # f"OInfo dataclass with fields access since IPython 8.12 please use OInfo.{field} instead." + # "OInfo used to be a dict but a dataclass provide static fields verification with mypy." + # "This warning and backward compatibility `get()` method were added in 8.13.", + # DeprecationWarning, + # stacklevel=2, + # ) + return getattr(self, field) + + def pylight(code): return highlight(code, PythonLexer(), HtmlFormatter(noclasses=True))