[BE][Easy] Fix PYI001: unprefixed-type-param in torch/utils/data/datapipes (#129885)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129885
Approved by: https://github.com/ezyang
This commit is contained in:
Xuehai Pan
2024-07-02 19:59:22 +08:00
committed by PyTorch MergeBot
parent 257b9c7936
commit f1df13f023
16 changed files with 150 additions and 136 deletions

View File

@ -9,10 +9,11 @@ from torch.utils.data.sampler import Sampler
__all__ = ["DistributedSampler"]
T_co = TypeVar("T_co", covariant=True)
_T_co = TypeVar("_T_co", covariant=True)
class DistributedSampler(Sampler[T_co]):
class DistributedSampler(Sampler[_T_co]):
r"""Sampler that restricts data loading to a subset of the dataset.
It is especially useful in conjunction with
@ -102,7 +103,7 @@ class DistributedSampler(Sampler[T_co]):
self.shuffle = shuffle
self.seed = seed
def __iter__(self) -> Iterator[T_co]:
def __iter__(self) -> Iterator[_T_co]:
if self.shuffle:
# deterministically shuffle based on epoch and seed
g = torch.Generator()