-
Notifications
You must be signed in to change notification settings - Fork 52
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
MNT Add non-strict mypy to CI and fix errors #62
MNT Add non-strict mypy to CI and fix errors #62
Conversation
This accompanies PR #61 to contrast the difference between strict and non-strict mypy usage.
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.
This looks much more reasonable to me.
Should also add it to pre-commit hooks.
@@ -112,7 +114,7 @@ def init(*, model: Union[str, Path], requirements: List[str], dst: Union[str, Pa | |||
None | |||
""" | |||
dst = Path(dst) | |||
if dst.exists() and next(dst.iterdir(), None): | |||
if dst.exists() and bool(next(dst.iterdir(), None)): |
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.
aha? why do we need explicit bool here? This is proper python:
>>> if 3 or None:
... print(1)
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.
The error is:
skops/hub_utils/_hf_hub.py:117: error: Argument 1 to "next" has incompatible type "Generator[Path, None, None]"; expected "SupportsNext[bool]"
skops/hub_utils/_hf_hub.py:117: error: Argument 2 to "next" has incompatible type "None"; expected "bool"
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.
That's very silly.
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.
Agree
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.
If you add the pre-commit hook here, I'm happy to merge this as a first step, and re-visit in the future.
@@ -112,7 +114,7 @@ def init(*, model: Union[str, Path], requirements: List[str], dst: Union[str, Pa | |||
None | |||
""" | |||
dst = Path(dst) | |||
if dst.exists() and next(dst.iterdir(), None): | |||
if dst.exists() and bool(next(dst.iterdir(), None)): |
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.
That's very silly.
E.g. def(foo: str = None)
They're not necessary to pass mypy but still useful to have.
skops/_min_dependencies.py
Outdated
@@ -16,7 +16,8 @@ | |||
"pytest": (PYTEST_MIN_VERSION, "tests", None), | |||
"pytest-cov": ("2.9.0", "tests", None), | |||
"flake8": ("3.8.2", "tests", None), | |||
"mypy": ("0.770", "tests", None), | |||
"mypy": ("0.971", "tests", None), |
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 isn't really a test dependency. It probably makes more sense to have it explicitly installed in CI the same as black and isort.
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.
Well, mypy was already there before, but sure, I'll remove it. I thought the idea of having it here is to have a single source of truth for all dependencies, so it made sense to me.
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.
Let's merge and see how it goes.
This accompanies PR #61 to contrast the difference between strict and
non-strict mypy usage.