Skip to content

Commit 3d844e9

Browse files
authored
Merge branch 'main' into main
2 parents 74a52e5 + 0a5479f commit 3d844e9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pyomo/common/enums.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
else:
4343
_EnumType = enum.EnumType
4444
if sys.version_info[:2] < (3, 13):
45+
import inspect
46+
4547
# prior to 3.13 the int.{to,from}_bytes docstrings had LaTeX-like
4648
# "`..'" quotations, which Sphinx can't parse correctly.
4749
def _fix_doc(ref):
@@ -53,7 +55,8 @@ def _rewrite(func):
5355

5456
class IntEnum(enum.IntEnum):
5557
__doc__ = (
56-
"""A compatibility wrapper around :class:`enum.IntEnum`
58+
inspect.cleandoc(
59+
"""A compatibility wrapper around :class:`enum.IntEnum`
5760
5861
This wrapper class updates the :meth:`to_bytes` and
5962
:meth:`from_bytes` docstrings in Python <= 3.12 to suppress
@@ -62,7 +65,10 @@ class IntEnum(enum.IntEnum):
6265
.. rubric:: IntEnum
6366
6467
"""
65-
+ enum.IntEnum.__doc__
68+
)
69+
+ "\n\n"
70+
# There are environments where IntEnum.__doc__ is None (see #3710)
71+
+ inspect.cleandoc(getattr(enum.IntEnum, "__doc__", "") or "")
6672
)
6773

6874
@_fix_doc(enum.IntEnum.to_bytes)

0 commit comments

Comments
 (0)