Skip to content

Commit 3155b5f

Browse files
[pre-commit.ci] pre-commit autoupdate (#1329)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.14 → v0.6.9](astral-sh/ruff-pre-commit@v0.1.14...v0.6.9) - [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.11.2](pre-commit/mirrors-mypy@v1.8.0...v1.11.2) - [github.com/python-jsonschema/check-jsonschema: 0.27.3 → 0.29.3](python-jsonschema/check-jsonschema@0.27.3...0.29.3) - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.5.0...v5.0.0) * fix(pre-commit): Minor fixes * maint: Update to 3.8 min --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: eddiebergman <eddiebergmanhs@gmail.com>
1 parent dea8724 commit 3155b5f

File tree

21 files changed

+240
-272
lines changed

21 files changed

+240
-272
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ files: |
77
)/.*\.py$
88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.1.14
10+
rev: v0.6.9
1111
hooks:
1212
- id: ruff
1313
args: [--fix, --exit-non-zero-on-fix, --no-cache]
1414
- id: ruff-format
1515
- repo: https://github.com/pre-commit/mirrors-mypy
16-
rev: v1.8.0
16+
rev: v1.11.2
1717
hooks:
1818
- id: mypy
1919
additional_dependencies:
2020
- types-requests
2121
- types-python-dateutil
2222
- repo: https://github.com/python-jsonschema/check-jsonschema
23-
rev: 0.27.3
23+
rev: 0.29.4
2424
hooks:
2525
- id: check-github-workflows
2626
files: '^github/workflows/.*\.ya?ml$'
2727
types: ["yaml"]
2828
- id: check-dependabot
2929
files: '^\.github/dependabot\.ya?ml$'
3030
- repo: https://github.com/pre-commit/pre-commit-hooks
31-
rev: v4.5.0
31+
rev: v5.0.0
3232
hooks:
3333
- id: check-added-large-files
3434
files: ".*"

openml/_api_calls.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def __is_checksum_equal(downloaded_file_binary: bytes, md5_checksum: str | None
351351
return md5_checksum == md5_checksum_download
352352

353353

354-
def _send_request( # noqa: C901
354+
def _send_request( # noqa: C901, PLR0912
355355
request_method: str,
356356
url: str,
357357
data: DATA_TYPE,
@@ -387,18 +387,15 @@ def _send_request( # noqa: C901
387387
# -- Check if encoding is not UTF-8 perhaps
388388
if __is_checksum_equal(response.content, md5_checksum):
389389
raise OpenMLHashException(
390-
"Checksum of downloaded file is unequal to the expected checksum {}"
391-
"because the text encoding is not UTF-8 when downloading {}. "
392-
"There might be a sever-sided issue with the file, "
393-
"see: https://github.com/openml/openml-python/issues/1180.".format(
394-
md5_checksum,
395-
url,
396-
),
390+
f"Checksum of downloaded file is unequal to the expected checksum"
391+
f"{md5_checksum} because the text encoding is not UTF-8 when "
392+
f"downloading {url}. There might be a sever-sided issue with the file, "
393+
"see: https://github.com/openml/openml-python/issues/1180.",
397394
)
398395

399396
raise OpenMLHashException(
400-
"Checksum of downloaded file is unequal to the expected checksum {} "
401-
"when downloading {}.".format(md5_checksum, url),
397+
f"Checksum of downloaded file is unequal to the expected checksum "
398+
f"{md5_checksum} when downloading {url}.",
402399
)
403400

404401
return response
@@ -464,7 +461,7 @@ def __parse_server_exception(
464461
server_exception = xmltodict.parse(response.text)
465462
except xml.parsers.expat.ExpatError as e:
466463
raise e
467-
except Exception as e: # noqa: BLE001
464+
except Exception as e:
468465
# OpenML has a sophisticated error system
469466
# where information about failures is provided. try to parse this
470467
raise OpenMLServerError(

openml/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""""Command Line Interface for `openml` to configure its settings."""
1+
"""Command Line Interface for `openml` to configure its settings."""
2+
23
from __future__ import annotations
34

45
import argparse

openml/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,17 @@ def _setup(config: _Config | None = None) -> None:
278278
_root_cache_directory.mkdir(exist_ok=True, parents=True)
279279
except PermissionError:
280280
openml_logger.warning(
281-
"No permission to create openml cache directory at %s! This can result in "
282-
"OpenML-Python not working properly." % _root_cache_directory,
281+
f"No permission to create openml cache directory at {_root_cache_directory}!"
282+
" This can result in OpenML-Python not working properly.",
283283
)
284284

285285
if cache_exists:
286286
_create_log_handlers()
287287
else:
288288
_create_log_handlers(create_file_handler=False)
289289
openml_logger.warning(
290-
"No permission to create OpenML directory at %s! This can result in OpenML-Python "
291-
"not working properly." % config_dir,
290+
f"No permission to create OpenML directory at {config_dir}! This can result in "
291+
" OpenML-Python not working properly.",
292292
)
293293

294294

openml/datasets/dataset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ def find_invalid_characters(string: str, pattern: str) -> str:
156156
)
157157

158158
if dataset_id is None:
159-
pattern = "^[\x00-\x7F]*$"
159+
pattern = "^[\x00-\x7f]*$"
160160
if description and not re.match(pattern, description):
161161
# not basiclatin (XSD complains)
162162
invalid_characters = find_invalid_characters(description, pattern)
163163
raise ValueError(
164164
f"Invalid symbols {invalid_characters} in description: {description}",
165165
)
166-
pattern = "^[\x00-\x7F]*$"
166+
pattern = "^[\x00-\x7f]*$"
167167
if citation and not re.match(pattern, citation):
168168
# not basiclatin (XSD complains)
169169
invalid_characters = find_invalid_characters(citation, pattern)
@@ -574,7 +574,7 @@ def _parse_data_from_file(self, data_file: Path) -> tuple[list[str], list[bool],
574574
def _parse_data_from_pq(self, data_file: Path) -> tuple[list[str], list[bool], pd.DataFrame]:
575575
try:
576576
data = pd.read_parquet(data_file)
577-
except Exception as e: # noqa: BLE001
577+
except Exception as e:
578578
raise Exception(f"File: {data_file}") from e
579579
categorical = [data[c].dtype.name == "category" for c in data.columns]
580580
attribute_names = list(data.columns)
@@ -816,7 +816,7 @@ def get_data( # noqa: C901, PLR0912, PLR0915
816816
to_exclude.extend(self.ignore_attribute)
817817

818818
if len(to_exclude) > 0:
819-
logger.info("Going to remove the following attributes: %s" % to_exclude)
819+
logger.info(f"Going to remove the following attributes: {to_exclude}")
820820
keep = np.array([column not in to_exclude for column in attribute_names])
821821
data = data.loc[:, keep] if isinstance(data, pd.DataFrame) else data[:, keep]
822822

openml/datasets/functions.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import warnings
77
from collections import OrderedDict
88
from pathlib import Path
9+
from pyexpat import ExpatError
910
from typing import TYPE_CHECKING, Any, overload
1011
from typing_extensions import Literal
1112

@@ -15,7 +16,6 @@
1516
import pandas as pd
1617
import urllib3
1718
import xmltodict
18-
from pyexpat import ExpatError
1919
from scipy.sparse import coo_matrix
2020

2121
import openml._api_calls
@@ -85,8 +85,7 @@ def list_datasets(
8585
*,
8686
output_format: Literal["dataframe"],
8787
**kwargs: Any,
88-
) -> pd.DataFrame:
89-
...
88+
) -> pd.DataFrame: ...
9089

9190

9291
@overload
@@ -98,8 +97,7 @@ def list_datasets(
9897
tag: str | None,
9998
output_format: Literal["dataframe"],
10099
**kwargs: Any,
101-
) -> pd.DataFrame:
102-
...
100+
) -> pd.DataFrame: ...
103101

104102

105103
@overload
@@ -111,8 +109,7 @@ def list_datasets(
111109
tag: str | None = ...,
112110
output_format: Literal["dict"] = "dict",
113111
**kwargs: Any,
114-
) -> pd.DataFrame:
115-
...
112+
) -> pd.DataFrame: ...
116113

117114

118115
def list_datasets(
@@ -207,17 +204,15 @@ def _list_datasets(
207204
data_id: list | None = ...,
208205
output_format: Literal["dict"] = "dict",
209206
**kwargs: Any,
210-
) -> dict:
211-
...
207+
) -> dict: ...
212208

213209

214210
@overload
215211
def _list_datasets(
216212
data_id: list | None = ...,
217213
output_format: Literal["dataframe"] = "dataframe",
218214
**kwargs: Any,
219-
) -> pd.DataFrame:
220-
...
215+
) -> pd.DataFrame: ...
221216

222217

223218
def _list_datasets(
@@ -256,18 +251,16 @@ def _list_datasets(
256251
for operator, value in kwargs.items():
257252
api_call += f"/{operator}/{value}"
258253
if data_id is not None:
259-
api_call += "/data_id/%s" % ",".join([str(int(i)) for i in data_id])
254+
api_call += "/data_id/{}".format(",".join([str(int(i)) for i in data_id]))
260255
return __list_datasets(api_call=api_call, output_format=output_format)
261256

262257

263258
@overload
264-
def __list_datasets(api_call: str, output_format: Literal["dict"] = "dict") -> dict:
265-
...
259+
def __list_datasets(api_call: str, output_format: Literal["dict"] = "dict") -> dict: ...
266260

267261

268262
@overload
269-
def __list_datasets(api_call: str, output_format: Literal["dataframe"]) -> pd.DataFrame:
270-
...
263+
def __list_datasets(api_call: str, output_format: Literal["dataframe"]) -> pd.DataFrame: ...
271264

272265

273266
def __list_datasets(
@@ -785,10 +778,8 @@ def create_dataset( # noqa: C901, PLR0912, PLR0915
785778
if not is_row_id_an_attribute:
786779
raise ValueError(
787780
"'row_id_attribute' should be one of the data attribute. "
788-
" Got '{}' while candidates are {}.".format(
789-
row_id_attribute,
790-
[attr[0] for attr in attributes_],
791-
),
781+
f" Got '{row_id_attribute}' while candidates are"
782+
f" {[attr[0] for attr in attributes_]}.",
792783
)
793784

794785
if isinstance(data, pd.DataFrame):

openml/evaluations/functions.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ def list_evaluations(
3232
per_fold: bool | None = ...,
3333
sort_order: str | None = ...,
3434
output_format: Literal["dict", "object"] = "dict",
35-
) -> dict:
36-
...
35+
) -> dict: ...
3736

3837

3938
@overload
@@ -51,8 +50,7 @@ def list_evaluations(
5150
per_fold: bool | None = ...,
5251
sort_order: str | None = ...,
5352
output_format: Literal["dataframe"] = ...,
54-
) -> pd.DataFrame:
55-
...
53+
) -> pd.DataFrame: ...
5654

5755

5856
def list_evaluations(
@@ -204,24 +202,24 @@ def _list_evaluations(
204202
-------
205203
dict of objects, or dataframe
206204
"""
207-
api_call = "evaluation/list/function/%s" % function
205+
api_call = f"evaluation/list/function/{function}"
208206
if kwargs is not None:
209207
for operator, value in kwargs.items():
210208
api_call += f"/{operator}/{value}"
211209
if tasks is not None:
212-
api_call += "/task/%s" % ",".join([str(int(i)) for i in tasks])
210+
api_call += "/task/{}".format(",".join([str(int(i)) for i in tasks]))
213211
if setups is not None:
214-
api_call += "/setup/%s" % ",".join([str(int(i)) for i in setups])
212+
api_call += "/setup/{}".format(",".join([str(int(i)) for i in setups]))
215213
if flows is not None:
216-
api_call += "/flow/%s" % ",".join([str(int(i)) for i in flows])
214+
api_call += "/flow/{}".format(",".join([str(int(i)) for i in flows]))
217215
if runs is not None:
218-
api_call += "/run/%s" % ",".join([str(int(i)) for i in runs])
216+
api_call += "/run/{}".format(",".join([str(int(i)) for i in runs]))
219217
if uploaders is not None:
220-
api_call += "/uploader/%s" % ",".join([str(int(i)) for i in uploaders])
218+
api_call += "/uploader/{}".format(",".join([str(int(i)) for i in uploaders]))
221219
if study is not None:
222220
api_call += "/study/%d" % study
223221
if sort_order is not None:
224-
api_call += "/sort_order/%s" % sort_order
222+
api_call += f"/sort_order/{sort_order}"
225223

226224
return __list_evaluations(api_call, output_format=output_format)
227225

@@ -236,7 +234,7 @@ def __list_evaluations(
236234
# Minimalistic check if the XML is useful
237235
if "oml:evaluations" not in evals_dict:
238236
raise ValueError(
239-
"Error in return XML, does not contain " '"oml:evaluations": %s' % str(evals_dict),
237+
"Error in return XML, does not contain " f'"oml:evaluations": {evals_dict!s}',
240238
)
241239

242240
assert isinstance(evals_dict["oml:evaluations"]["oml:evaluation"], list), type(

0 commit comments

Comments
 (0)