Open NiklasKappel opened 9 months ago
If you want to make your code pyright
compatible, you can just do assert isinstance(train_dataset, TUDataset)
before passing it to the train_loader
. The real fix is to use @overload
as part of Dataset.__getitem__
. We are working on this as part of making whole PyG mypy
compatible.
š Describe the bug
For the following code (extracted from here)
Pyright raises the error
Argument of type "Dataset | BaseData" cannot be assigned to parameter "dataset" of type "Dataset | Sequence[BaseData] | DatasetAdapter" in function "__init__"
. This seems to be because__getitem__
ofDataset
returnsUnion['Dataset', BaseData]
here butDataLoader
does not acceptBaseData
objects here.Edit: Bonus question: Should the pytorch
Subset
type be explicitly supported, so that one can use random_split without having type checkers complain?Versions