Skip to content

Commit b86eb33

Browse files
committed
Fix circular import issue
Signed-off-by: Samet Akcay <[email protected]>
1 parent 28e951f commit b86eb33

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/anomalib/visualization/image/visualizer.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
from pathlib import Path
7-
from typing import Any
7+
from typing import TYPE_CHECKING, Any
88

9-
from lightning.pytorch import Trainer
9+
# Only import types during type checking to avoid circular imports
10+
if TYPE_CHECKING:
11+
from lightning.pytorch import Trainer
12+
13+
from anomalib.data import ImageBatch
14+
from anomalib.models import AnomalibModule
1015

11-
from anomalib.data import ImageBatch
12-
from anomalib.models.components.base import AnomalibModule
1316
from anomalib.utils.path import generate_output_filename
1417
from anomalib.visualization.base import Visualizer
1518

@@ -139,10 +142,10 @@ def __init__(
139142

140143
def on_test_batch_end(
141144
self,
142-
trainer: Trainer,
143-
pl_module: AnomalibModule,
144-
outputs: ImageBatch,
145-
batch: ImageBatch,
145+
trainer: "Trainer",
146+
pl_module: "AnomalibModule",
147+
outputs: "ImageBatch",
148+
batch: "ImageBatch",
146149
batch_idx: int,
147150
dataloader_idx: int = 0,
148151
) -> None:
@@ -177,10 +180,10 @@ def on_test_batch_end(
177180

178181
def on_predict_batch_end(
179182
self,
180-
trainer: Trainer,
181-
pl_module: AnomalibModule,
182-
outputs: ImageBatch,
183-
batch: ImageBatch,
183+
trainer: "Trainer",
184+
pl_module: "AnomalibModule",
185+
outputs: "ImageBatch",
186+
batch: "ImageBatch",
184187
batch_idx: int,
185188
dataloader_idx: int = 0,
186189
) -> None:

0 commit comments

Comments
 (0)