data icon indicating copy to clipboard operation
data copied to clipboard

Support for recursive datatypes

Open abhi-glitchhg opened this issue 3 years ago • 7 comments

since release of mypy 0.981 recursive types are supported; i have just removed the # as per suggestion in the TODO comment and have changed the mypy version in the ci jobs.

This PR is to check if ci is breaking with the changes are not. fixes #640

Let me know if any further changes need to be made thanks..

abhi-glitchhg avatar Oct 28 '22 15:10 abhi-glitchhg

Hmm, mypy is raising one error on this line

returning TypeVar should receive at least one argument containing the same
Typevar  [type-var]
Found 1 error in 1 file (checked 76 source files)
        def draw(self) -> T:

https://github.com/pytorch/data/blob/b1b3406389fa6665ec3422ae5e1ebf65ae7e2938/torchdata/datapipes/iter/util/randomsplitter.py#L103-L105

How can i fix this? can anyone help me out here?

abhi-glitchhg avatar Nov 07 '22 19:11 abhi-glitchhg

Based on this issue, it seems to be warning that a single TypeVar will not do anything. I think you can either remove -> T or suppress the warning.

NivekT avatar Nov 07 '22 20:11 NivekT

@NivekT has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Nov 08 '22 17:11 facebook-github-bot

hello @ejguan! Thanks for the feedback.

Make TorchData fully out of PyTorch

Honestly, I do not know the consequences and the amount of work required for this but the second option seems easier than the first.

Anyway, there is no hurry from my side; I just noticed the TODO issue and was aware of the recent mypy version release.

We could try updating the pytorch's mypy version. Are there any existing blockers in doing this that you are aware of?

Would love to hear your thoughts. Thanks!

abhi-glitchhg avatar Nov 09 '22 17:11 abhi-glitchhg

BTW, regarding the recursive type hints, 0.981 is not the best version as it's an experimental feature. 0.990 is the version that officially supports recursive type hints.

ejguan avatar Nov 09 '22 17:11 ejguan

Let's wait until PyTorch has officially updated mypy

ejguan avatar Nov 09 '22 17:11 ejguan

BTW, regarding the recursive type hints, 0.981 is not the best version as it's an experimental feature. 0.990 is the version that officially supports recursive type hints.

I was just going to mention this.

abhi-glitchhg avatar Nov 09 '22 17:11 abhi-glitchhg