Skip to content

Commit

Permalink
Backport PR #14033 on branch 8.12.x (MAINT: reintroduce a OInfo get m…
Browse files Browse the repository at this point in the history
…ethod for backward compatibility.) (#14048)

Backport PR #14033: MAINT: reintroduce a OInfo get method for backward
compatibility.
  • Loading branch information
Carreau committed Apr 28, 2023
2 parents 1f165ad + 4524687 commit 76d449e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions IPython/core/oinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 76d449e

Please sign in to comment.