-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for recursive datatypes #866
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ejguan Any issue form upgrading mypy
to a newer version? Aside from fixing the lints?
Hmm, mypy is raising one error on this line
data/torchdata/datapipes/iter/util/randomsplitter.py Lines 103 to 105 in b1b3406
How can i fix this? can anyone help me out here? |
Based on this issue, it seems to be warning that a single TypeVar will not do anything. I think you can either remove |
@NivekT has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution. The PR looks good. However, I am sorry that I have to block this PR for now until PyTorch Core has updated their pinned mypy version from 0.960
to 0.981
.
The main problem is that torchdata is still partially in the tree of PyTorch. And PyTorch has strong opinion on the version of mypy
. See: https://github.com/pytorch/pytorch/blob/6bb7f4f29f0a36ce410ce53d824f531eaf74c76e/mypy.ini#L5
If we make this PR landed, in order to develop torchdata without mypy
complain on my local environment, I have to update mypy
to 0.981. However, if I need to work on something in PyTorch Core, the updated mypy
will prevent me running static type checking on PyTorch.
IMHO, to land this PR, we accomplish one of the following 2 options:
- Make TorchData fully out of PyTorch
- Update PyTorch's
mypy
requirement
LMK if it makes sense. And, please correct me if anything wrong or we have other options.
hello @ejguan! Thanks for the feedback.
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. |
@@ -64,7 +64,7 @@ jobs: | |||
run: | | |||
set -eux | |||
STATUS= | |||
if ! mypy --config=mypy.ini; then | |||
if ! mypy --config=mypy.ini --enable-recursive-aliases --install-types --non-interactive; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also like to point out that, --install-types --non-interactive
will install the missing package stubs hence slower.
Quoting relevant part from the above documentation link :- This is somewhat slower than explicitly installing stubs before running mypy, since it may type check your code twice – the first time to find the missing stubs, and the second time to type check your code properly after mypy has installed the stubs.
I don't think downloading the package stubs would be a bottleneck; but if it is, then we could think of using cached installations. (just a suggestion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for providing the idea. I think it's fine for now as torchdata is still a small package. We might want to investigate if we have noticed significant overhead.
BTW, regarding the recursive type hints, |
Let's wait until PyTorch has officially updated mypy |
I was just going to mention this. |
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..