Skip to content
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

Merged
merged 3 commits into from
Nov 24, 2020

Conversation

skshetry
Copy link
Member

@skshetry skshetry commented Nov 24, 2020

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:

$ mypy -p dvc

Thank you for the contribution - we'll try to review it as soon as possible. 🙏

@skshetry skshetry added testing Related to the tests and the testing infrastructure skip-changelog Skips changelog labels Nov 24, 2020
@skshetry skshetry requested a review from efiop November 24, 2020 06:42
@skshetry skshetry self-assigned this Nov 24, 2020
@@ -42,7 +42,6 @@ def __init__(self, key, new, into):
)
return

assert isinstance(new, Node) and isinstance(into[key], Node)
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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.

mypy.ini Outdated Show resolved Hide resolved
@@ -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
Copy link
Member Author

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.

@skshetry skshetry merged commit d138bdd into iterative:master Nov 24, 2020
@skshetry skshetry deleted the add-mypy branch November 24, 2020 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Skips changelog testing Related to the tests and the testing infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants