-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add mypy config, fix type errors in a few remaining places #4951
Conversation
@@ -42,7 +42,6 @@ def __init__(self, key, new, into): | |||
) | |||
return | |||
|
|||
assert isinstance(new, Node) and isinstance(into[key], Node) |
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.
There was already a "if" clause checking it's negation. :)
with suppress(FileNotFoundError): | ||
return self.sftp.lstat(path).st_mode |
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.
mypy
had problem figuring out return type here. Dunno why.
open_fn = tree.open if tree else open | ||
with open_fn(path, "w+", encoding="utf-8") as fd: | ||
with open_fn(path, "w+", encoding="utf-8") as fd: # type: ignore |
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 need to fix PathInfo
situation soon, if we need to keep adding more types.
@@ -1,34 +1,70 @@ | |||
"""Common utilities for serialize.""" | |||
import os | |||
from contextlib import contextmanager | |||
from typing import TYPE_CHECKING, Any, Callable, ContextManager, Dict, Union | |||
|
|||
from typing_extensions import Protocol |
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.
Need to add this package on conda_forge too.
I haven't added it to the CI yet, as it will only confuse the contributors. We should add it after we have significant type coverage.
To run that locally, just run:
❗ I have followed the Contributing to DVC checklist.
📖 If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.
Thank you for the contribution - we'll try to review it as soon as possible. 🙏