-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Annotation Problem *.pyi #26673
Comments
(Python 2 support will be dropped #23795) |
I think everyone would be onboard to move to inline type annotations once Python 2 support is dropped. The current preference was to use stubs instead of comment-based annotations. Was there a specific incorrect stub? |
We'll wait for Python 2 EOL, and move all annotation inline using Python 3 syntax. |
It looks like More generically, there should probably be a test that checks that the stubs agree with the actual implementation, at least so long as the mypy type information is in a separate file from the implementation. I'll go ahead and put in a pull request this afternoon that hopefully fixes the specific issue with the type stubs for |
Thanks! There are some tests for the most important stubs but they are far
from comprehensive at the moment.
…On Mon, Sep 30, 2019 at 3:52 PM Nathan Goldbaum ***@***.***> wrote:
Was there a specific incorrect stub?
It looks like _DataLoaderIter is now called _BaseDataLoaderIter and needs
to be renamed and updated in the stubs (and possibly the various subclasses
need to be added as well).
More generically, there should probably be a test that checks that the
stubs agree with the actual implementation, at least so long as the mypy
type information is in a separate file from the implementation.
I'll go ahead and put in a pull request this afternoon that hopefully
fixes the specific issue with the type stubs for _BaseDataLoaderIter,
this is my first pytorch issue so bear with me :)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#26673?email_source=notifications&email_token=AAHRFPIF5EWAHI74MYRIPUDQMJKIVA5CNFSM4IZTBI22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD764CUQ#issuecomment-536723794>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHRFPPNDKCNL3NOFMORVP3QMJKIVANCNFSM4IZTBI2Q>
.
|
I guess ultimately the issue here is that only one file -- |
Summary: Back in April, malmaud added type annotations for `dataloader.py`. However, at about the same time, SsnL in #19228 replaced `_DataLoaderIter` with `_BaseDataLoaderIter` and two subclasses, `_SingleProcessDataLoaderIter`, and `_MultiProcessingDataLoaderIter`. However - probably because these changes happened in parallel at roughly the same time, the type stubs and several other references in the codebase were never updated to match this refactoring. I've gone ahead and done the updates to reflect the refactoring in #19228, which fixes the specific type stub/impelementation mismatch pointed out in #26673, although not the broader problem that pytorch doesn't have a test to make sure that the `.pyi` type stub files match the real API defined in `.py` files. Pull Request resolved: #27105 Differential Revision: D17813641 Pulled By: ezyang fbshipit-source-id: ed7ac025c8d6ad3f298dd073347ec83bb4b6600c
The specific issue pointed out here has been fixed, so I'm going to close this in favor of #16574 which tracks broader improvements to type correctness. |
…ch#27105) Summary: Back in April, malmaud added type annotations for `dataloader.py`. However, at about the same time, SsnL in pytorch#19228 replaced `_DataLoaderIter` with `_BaseDataLoaderIter` and two subclasses, `_SingleProcessDataLoaderIter`, and `_MultiProcessingDataLoaderIter`. However - probably because these changes happened in parallel at roughly the same time, the type stubs and several other references in the codebase were never updated to match this refactoring. I've gone ahead and done the updates to reflect the refactoring in pytorch#19228, which fixes the specific type stub/impelementation mismatch pointed out in pytorch#26673, although not the broader problem that pytorch doesn't have a test to make sure that the `.pyi` type stub files match the real API defined in `.py` files. Pull Request resolved: pytorch#27105 Differential Revision: D17813641 Pulled By: ezyang fbshipit-source-id: ed7ac025c8d6ad3f298dd073347ec83bb4b6600c
🚀 Feature
It is difficult to control the validity of function arguments when they are in different files.
Very often the information in *.pyi does not match *.py.
pytorch/torch/utils/data/dataloader.pyi
Line 35 in fcd1354
I suggest using Python 2 Annotations:
You can expand this format to indicate in which file to place annotations.
After that, all *.pyi can be completely assembled in one script. Information will always be up to date.
cc @ezyang @gchanan @zou3519
The text was updated successfully, but these errors were encountered: