Skip to content

Conversation

@mfeurer
Copy link
Collaborator

@mfeurer mfeurer commented Jun 15, 2023

This commit adds mypy annotations for _api_calls.py to make sure that we have no untyped classes and functions.

@codecov-commenter
Copy link

codecov-commenter commented Jun 15, 2023

Codecov Report

Patch coverage: 65.15% and project coverage change: -52.10 ⚠️

Comparison is base (3b3553b) 81.66% compared to head (26fe6d7) 29.57%.

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     
Impacted Files Coverage Δ
openml/runs/functions.py 11.08% <ø> (-64.34%) ⬇️
openml/setups/functions.py 17.18% <0.00%> (-68.75%) ⬇️
openml/study/functions.py 18.89% <0.00%> (-71.66%) ⬇️
openml/datasets/data_feature.py 67.85% <50.00%> (-1.38%) ⬇️
openml/datasets/dataset.py 30.72% <58.92%> (-55.06%) ⬇️
openml/datasets/functions.py 42.59% <65.90%> (-45.66%) ⬇️
openml/utils.py 53.29% <90.00%> (-38.59%) ⬇️
openml/_api_calls.py 61.36% <100.00%> (-22.82%) ⬇️
openml/tasks/functions.py 54.01% <100.00%> (-29.69%) ⬇️

... and 17 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mfeurer mfeurer requested a review from PGijsbers June 15, 2023 12:08
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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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]

Copy link
Collaborator

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.

Copy link
Collaborator

@PGijsbers PGijsbers left a 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.
@mfeurer mfeurer force-pushed the mypy-annotate-api_calls branch from 26be89d to 26fe6d7 Compare June 16, 2023 06:29
@mfeurer mfeurer merged commit 80a028a into develop Jun 16, 2023
@mfeurer mfeurer deleted the mypy-annotate-api_calls branch June 16, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants