Skip to content

Commit f9412d3

Browse files
pre-commit-ci[bot]LennartPuruckermfeurer
authored
[pre-commit.ci] pre-commit autoupdate (#1223)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 22.6.0 → 23.3.0](psf/black@22.6.0...23.3.0) - [github.com/pre-commit/mirrors-mypy: v0.961 → v1.2.0](pre-commit/mirrors-mypy@v0.961...v1.2.0) - [github.com/pycqa/flake8: 4.0.1 → 6.0.0](PyCQA/flake8@4.0.1...6.0.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix mypy errors: made implicit optional typing to be explicit * Drop duplicate flake8 config * Fix a few flake8 issues * Update python version for pre-commit workflow --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lennart Purucker <lennart.purucker@uni-siegen.de> Co-authored-by: Matthias Feurer <feurerm@informatik.uni-freiburg.de>
1 parent fb9f9eb commit f9412d3

33 files changed

Lines changed: 46 additions & 116 deletions

.github/workflows/pre-commit.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v3
10-
- name: Setup Python 3.7
10+
- name: Setup Python 3.8
1111
uses: actions/setup-python@v4
1212
with:
13-
python-version: 3.7
13+
python-version: 3.8
1414
- name: Install pre-commit
1515
run: |
1616
pip install pre-commit

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 22.6.0
3+
rev: 23.3.0
44
hooks:
55
- id: black
66
args: [--line-length=100]
77
- repo: https://github.com/pre-commit/mirrors-mypy
8-
rev: v0.961
8+
rev: v1.2.0
99
hooks:
1010
- id: mypy
1111
name: mypy openml
@@ -20,7 +20,7 @@ repos:
2020
- types-requests
2121
- types-python-dateutil
2222
- repo: https://github.com/pycqa/flake8
23-
rev: 4.0.1
23+
rev: 6.0.0
2424
hooks:
2525
- id: flake8
2626
name: flake8 openml

doc/progress.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ Changelog
99
0.13.1
1010
~~~~~~
1111

12-
* DOC #1241 #1229 #1231: Minor documentation fixes and resolve documentation examples not working.
1312
* ADD #1028: Add functions to delete runs, flows, datasets, and tasks (e.g., ``openml.datasets.delete_dataset``).
1413
* ADD #1144: Add locally computed results to the ``OpenMLRun`` object's representation if the run was created locally and not downloaded from the server.
1514
* ADD #1180: Improve the error message when the checksum of a downloaded dataset does not match the checksum provided by the API.
1615
* ADD #1201: Make ``OpenMLTraceIteration`` a dataclass.
1716
* DOC #1069: Add argument documentation for the ``OpenMLRun`` class.
17+
* DOC #1241 #1229 #1231: Minor documentation fixes and resolve documentation examples not working.
1818
* FIX #1197 #559 #1131: Fix the order of ground truth and predictions in the ``OpenMLRun`` object and in ``format_prediction``.
1919
* FIX #1198: Support numpy 1.24 and higher.
2020
* FIX #1216: Allow unknown task types on the server. This is only relevant when new task types are added to the test server.
21+
* FIX #1223: Fix mypy errors for implicit optional typing.
2122
* MAINT #1155: Add dependabot github action to automatically update other github actions.
2223
* MAINT #1199: Obtain pre-commit's flake8 from github.com instead of gitlab.com.
2324
* MAINT #1215: Support latest numpy version.

examples/30_extended/fetch_runtimes_tutorial.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
)
8080
)
8181

82+
8283
# Creating utility function
8384
def print_compare_runtimes(measures):
8485
for repeat, val1 in measures["usercpu_time_millis_training"].items():

openml/_api_calls.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def _download_minio_bucket(
195195
def _download_text_file(
196196
source: str,
197197
output_path: Optional[str] = None,
198-
md5_checksum: str = None,
198+
md5_checksum: Optional[str] = None,
199199
exists_ok: bool = True,
200200
encoding: str = "utf8",
201201
) -> Optional[str]:
@@ -326,7 +326,6 @@ def _send_request(request_method, url, data, files=None, md5_checksum=None):
326326
if request_method == "get" and not __is_checksum_equal(
327327
response.text.encode("utf-8"), md5_checksum
328328
):
329-
330329
# -- Check if encoding is not UTF-8 perhaps
331330
if __is_checksum_equal(response.content, md5_checksum):
332331
raise OpenMLHashException(

openml/datasets/dataset.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ def _get_repr_body_fields(self) -> List[Tuple[str, Union[str, int, List[str]]]]:
274274
return [(key, fields[key]) for key in order if key in fields]
275275

276276
def __eq__(self, other):
277-
278277
if not isinstance(other, OpenMLDataset):
279278
return False
280279

openml/datasets/functions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def list_datasets(
7474
output_format: str = "dict",
7575
**kwargs,
7676
) -> Union[Dict, pd.DataFrame]:
77-
7877
"""
7978
Return a list of all dataset which are on OpenML.
8079
Supports large amount of results.
@@ -182,7 +181,6 @@ def _list_datasets(data_id: Optional[List] = None, output_format="dict", **kwarg
182181

183182

184183
def __list_datasets(api_call, output_format="dict"):
185-
186184
xml_string = openml._api_calls._perform_api_call(api_call, "get")
187185
datasets_dict = xmltodict.parse(xml_string, force_list=("oml:dataset",))
188186

@@ -353,7 +351,7 @@ def get_datasets(
353351
def get_dataset(
354352
dataset_id: Union[int, str],
355353
download_data: bool = True,
356-
version: int = None,
354+
version: Optional[int] = None,
357355
error_if_multiple: bool = False,
358356
cache_format: str = "pickle",
359357
download_qualities: bool = True,
@@ -984,7 +982,7 @@ def _get_dataset_description(did_cache_dir, dataset_id):
984982

985983
def _get_dataset_parquet(
986984
description: Union[Dict, OpenMLDataset],
987-
cache_directory: str = None,
985+
cache_directory: Optional[str] = None,
988986
download_all_files: bool = False,
989987
) -> Optional[str]:
990988
"""Return the path to the local parquet file of the dataset. If is not cached, it is downloaded.
@@ -1051,7 +1049,9 @@ def _get_dataset_parquet(
10511049
return output_file_path
10521050

10531051

1054-
def _get_dataset_arff(description: Union[Dict, OpenMLDataset], cache_directory: str = None) -> str:
1052+
def _get_dataset_arff(
1053+
description: Union[Dict, OpenMLDataset], cache_directory: Optional[str] = None
1054+
) -> str:
10551055
"""Return the path to the local arff file of the dataset. If is not cached, it is downloaded.
10561056
10571057
Checks if the file is in the cache, if yes, return the path to the file.
@@ -1173,8 +1173,8 @@ def _create_dataset_from_description(
11731173
description: Dict[str, str],
11741174
features_file: str,
11751175
qualities_file: str,
1176-
arff_file: str = None,
1177-
parquet_file: str = None,
1176+
arff_file: Optional[str] = None,
1177+
parquet_file: Optional[str] = None,
11781178
cache_format: str = "pickle",
11791179
) -> OpenMLDataset:
11801180
"""Create a dataset object from a description dict.

openml/exceptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# License: BSD 3-Clause
22

3+
from typing import Optional
4+
35

46
class PyOpenMLError(Exception):
57
def __init__(self, message: str):
@@ -20,7 +22,7 @@ class OpenMLServerException(OpenMLServerError):
2022

2123
# Code needs to be optional to allow the exception to be picklable:
2224
# https://stackoverflow.com/questions/16244923/how-to-make-a-custom-exception-class-with-multiple-init-args-pickleable # noqa: E501
23-
def __init__(self, message: str, code: int = None, url: str = None):
25+
def __init__(self, message: str, code: Optional[int] = None, url: Optional[str] = None):
2426
self.message = message
2527
self.code = code
2628
self.url = url

openml/extensions/extension_interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def _run_model_on_fold(
166166
y_train: Optional[np.ndarray] = None,
167167
X_test: Optional[Union[np.ndarray, scipy.sparse.spmatrix]] = None,
168168
) -> Tuple[np.ndarray, np.ndarray, "OrderedDict[str, float]", Optional["OpenMLRunTrace"]]:
169-
"""Run a model on a repeat,fold,subsample triplet of the task and return prediction information.
169+
"""Run a model on a repeat, fold, subsample triplet of the task.
170170
171171
Returns the data that is necessary to construct the OpenML Run object. Is used by
172172
:func:`openml.runs.run_flow_on_task`.

openml/extensions/sklearn/extension.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,6 @@ def flatten_all(list_):
10211021
# when deserializing the parameter
10221022
sub_components_explicit.add(identifier)
10231023
if isinstance(sub_component, str):
1024-
10251024
external_version = self._get_external_version_string(None, {})
10261025
dependencies = self._get_dependencies()
10271026
tags = self._get_tags()
@@ -1072,7 +1071,6 @@ def flatten_all(list_):
10721071
parameters[k] = parameter_json
10731072

10741073
elif isinstance(rval, OpenMLFlow):
1075-
10761074
# A subcomponent, for example the base model in
10771075
# AdaBoostClassifier
10781076
sub_components[k] = rval
@@ -1762,7 +1760,6 @@ def _prediction_to_probabilities(
17621760
)
17631761

17641762
if isinstance(task, (OpenMLClassificationTask, OpenMLLearningCurveTask)):
1765-
17661763
try:
17671764
proba_y = model_copy.predict_proba(X_test)
17681765
proba_y = pd.DataFrame(proba_y, columns=model_classes) # handles X_test as numpy

0 commit comments

Comments
 (0)