How to correctly write type annotation for Subset of extended Dataset class?

In this code, the static code analyzer show error with it says “targets not defined in dataset”.
If targets are defined in extended class of Dataset, how to correctly type annotate about this?

from typing import Sequence
from import Dataset, Subset

def log_class_statistics(subset: Subset):
    train_classes = [subset.dataset.targets[i] for i in subset.indices]

class ExtDataset(Dataset):
    targets: Sequence[int]

subset = Subset(ExtDatset(...))