Skip to content

Commit 49c0db9

Browse files
committed
Fix Model circular import using TYPE_CHECKING and lazy import
1 parent 3079404 commit 49c0db9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pymc/printing.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515

1616
import re
17-
1817
from functools import partial
18+
from typing import TYPE_CHECKING
1919

2020
from pytensor.compile import SharedVariable
2121
from pytensor.graph.basic import Constant
@@ -26,7 +26,9 @@
2626
from pytensor.tensor.random.type import RandomType
2727
from pytensor.tensor.type_other import NoneTypeT
2828

29-
from pymc.model import Model
29+
if TYPE_CHECKING:
30+
from pymc.model import Model
31+
3032

3133
__all__ = [
3234
"str_for_dist",
@@ -301,6 +303,7 @@ def _default_repr_pretty(obj: TensorVariable | Model, p, cycle):
301303
try:
302304
# register our custom pretty printer in ipython shells
303305
import IPython
306+
from pymc.model.core import Model
304307

305308
IPython.lib.pretty.for_type(TensorVariable, _default_repr_pretty)
306309
IPython.lib.pretty.for_type(Model, _default_repr_pretty)

0 commit comments

Comments
 (0)