-
-
Notifications
You must be signed in to change notification settings - Fork 211
Add mypy annotations for _api_calls.py #1257
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
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #1257 +/- ##
============================================
- Coverage 81.66% 29.57% -52.10%
============================================
Files 38 38
Lines 5012 5076 +64
============================================
- Hits 4093 1501 -2592
- Misses 919 3575 +2656
☔ View full report in Codecov by Sentry. |
openml/datasets/functions.py
Outdated
| import os | ||
| from pyexpat import ExpatError | ||
| from typing import List, Dict, Union, Optional, cast | ||
| from typing import List, Dict, Optional, Tuple, Union, cast # noqa: F401 |
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.
Why do we need a noqa here?
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.
Indeed, that's not necessary. Will remove.
|
|
||
| # compose data edit parameters as xml | ||
| form_data = {"data_id": data_id} | ||
| form_data = {"data_id": data_id} # type: openml._api_calls.DATA_TYPE |
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.
why not annotate the data_id parameter instead?
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.
Because from my understanding we would then get Dict[str, int] while the function expects Dict[str, Union[str, int]] as an argument.
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.
Since int is compatible with Union[str, int] I don't think that's an issue.
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 what I though as well, but no: openml/datasets/functions.py:895: error: Argument "data" to "_perform_api_call" has incompatible type "Dict[str, int]"; expected "Optional[Dict[str, Union[str, int]]]" [arg-type]
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.
cannot reproduce MWE, it's fine for now and we revisit when the rest of the file gets annotated.
PGijsbers
left a comment
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.
OK, though I think there is one annotation that should probably be changed.
This commit adds mypy annotations for _api_calls.py to make sure that we have no untyped classes and functions.
26be89d to
26fe6d7
Compare
This commit adds mypy annotations for _api_calls.py to make sure that we have no untyped classes and functions.