Skip to content

Commit 6211fd4

Browse files
SeanNarenJeff Yang
and
Jeff Yang
authored
Fix type checker issue with explicit cast of ref_model object (#4457)
Co-authored-by: Jeff Yang <[email protected]>
1 parent 1d594c5 commit 6211fd4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pytorch_lightning/trainer/properties.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import os
1616
from abc import ABC
1717
from argparse import ArgumentParser, Namespace
18-
from typing import List, Optional, Union, Type, TypeVar
18+
from typing import List, Optional, Union, Type, TypeVar, cast
1919

2020
from pytorch_lightning.callbacks import Callback, ProgressBarBase, ModelCheckpoint
2121
from pytorch_lightning.core.lightning import LightningModule
@@ -154,6 +154,7 @@ def progress_bar_callback(self):
154154
def progress_bar_dict(self) -> dict:
155155
""" Read-only for progress bar metrics. """
156156
ref_model = self.model if not self.data_parallel else self.model.module
157+
ref_model = cast(LightningModule, ref_model)
157158
return dict(**ref_model.get_progress_bar_dict(), **self.logger_connector.progress_bar_metrics)
158159

159160
@property

0 commit comments

Comments
 (0)