-
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
Attempt to fix mypy failure on ci #8128
Conversation
if root is not None: | ||
self.root: str = root | ||
else: | ||
self.root = root # 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.
Thanks for fixing this @vfdev-5
Would it work to just write this line unconditionally?
If there's no cleaner why to please mypy here, I'd suggest to stop type-checking this part of the code-base. It's not worth wasting time on.
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'm not sure if we can write it in single line...
Technically, mypy is right as root
arg is Optional[str]
, so self.root
type is Optional[str]
. In subclasses we are passing root string, but self.root
inherits the original type: Optional[str]
.
we can force the cast as (+/- some type ignores)
self.root: str = root
but this wont be correct.
Alternatively, as you say we can stop type checking this code and all related subclasses...
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.
Just seen that this PR is on the origin of this problem: #8124
Superseded by #8134. |
Fixed failing job "Lint / python-types / linux-job" : https://github.com/pytorch/vision/actions/runs/6955317152/job/18923844284?pr=8128