-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Added typing annotations to io/__init__ #4224
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
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.
@frgfm I changed the return type for self. See my commit.
return self | ||
|
||
def seek(self, time_s: float): | ||
def seek(self, time_s: float) -> 'VideoReader': |
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.
Could be replaced with VideoReader
once we drop Python 3.6 support. See here.
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.
Nice.
I learn something new everyday because of review from torchvision maintainers 😇
There are couple of more places where I have used this workaround in typing in torchvision. I will keep a note of this point.
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.
@datumbox yup fully agree! But for now (this PR), I guess we keep the string version?
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.
yes that's right, nothing we can do for now.
@@ -126,10 +127,10 @@ def __next__(self): | |||
raise StopIteration | |||
return {"data": frame, "pts": pts} | |||
|
|||
def __iter__(self): | |||
def __iter__(self) -> Iterator['VideoReader']: |
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.
See mypy doc.
@frgfm could you please merge master to clear the CI errors? |
@datumbox all errors were cleared after the previous merge 👌 |
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.
LGTM, thanks!
Summary: * style: Added typing annotations * Specified types for iter and seek. Reviewed By: fmassa Differential Revision: D30793319 fbshipit-source-id: b5d3a220639d239f64cee6712aa07e19fdaaf875 Co-authored-by: Vasilis Vryniotis <[email protected]> Co-authored-by: Vasilis Vryniotis <[email protected]>
Following up on #2025, this PR adds missing typing annotations in
io/__init__.py
.Note to reviewers: I'm not sure about the return types when a method returns
self
🤷♂️Any feedback is welcome!