-
Notifications
You must be signed in to change notification settings - Fork 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
fix mypy on VisionDataset
#8134
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8134
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (3 Unrelated Failures)As of commit 9ae3188 with merge base 83090c2 (): BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@@ -31,7 +31,7 @@ def __init__( | |||
target_transform: Optional[Callable] = None, | |||
random_offset: int = 0, | |||
) -> None: | |||
super().__init__(None, transform=transform, target_transform=target_transform) # type: ignore[arg-type] | |||
super().__init__(transform=transform, target_transform=target_transform) |
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.
Driveby, since we no longer need to pass None
after #8124.
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.
Thanks Philip. One Q but LGTM anyway
@@ -29,7 +29,7 @@ class VisionDataset(data.Dataset): | |||
|
|||
def __init__( | |||
self, | |||
root: Optional[str] = None, | |||
root: str = None, # type: ignore[assignment] |
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.
can we still keep the Optional[str]
type which is technically correct?
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.
We can't. If we use Optional[str]
as annotation, mypy
correctly infers that for the self.root
attribute. And with that we are back at the issues we are currently seeing, i.e. all child datasets that perform anything with self.root
would now need to check that self.root
is in fact a str
and not None
.
Reviewed By: vmoens Differential Revision: D52539016 fbshipit-source-id: d1726730d1d432b32f1ab36699ec5e361be75652
Supersedes #8128. Error caused by #8124.