Skip to content

Commit fd55835

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent cfdfc7d commit fd55835

File tree

12 files changed

+61
-121
lines changed

12 files changed

+61
-121
lines changed

openml/_api_calls.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,18 +366,15 @@ def _send_request( # noqa: C901
366366
# -- Check if encoding is not UTF-8 perhaps
367367
if __is_checksum_equal(response.content, md5_checksum):
368368
raise OpenMLHashException(
369-
"Checksum of downloaded file is unequal to the expected checksum {}"
370-
"because the text encoding is not UTF-8 when downloading {}. "
369+
f"Checksum of downloaded file is unequal to the expected checksum {md5_checksum}"
370+
f"because the text encoding is not UTF-8 when downloading {url}. "
371371
"There might be a sever-sided issue with the file, "
372-
"see: https://github.com/openml/openml-python/issues/1180.".format(
373-
md5_checksum,
374-
url,
375-
),
372+
"see: https://github.com/openml/openml-python/issues/1180.",
376373
)
377374

378375
raise OpenMLHashException(
379-
"Checksum of downloaded file is unequal to the expected checksum {} "
380-
"when downloading {}.".format(md5_checksum, url),
376+
f"Checksum of downloaded file is unequal to the expected checksum {md5_checksum} "
377+
f"when downloading {url}.",
381378
)
382379

383380
return response

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/datasets/dataset.py

Lines changed: 2 additions & 2 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)

openml/datasets/functions.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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(
@@ -261,13 +256,11 @@ def _list_datasets(
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(
@@ -804,10 +797,7 @@ def create_dataset( # noqa: C901, PLR0912, PLR0915
804797
if not is_row_id_an_attribute:
805798
raise ValueError(
806799
"'row_id_attribute' should be one of the data attribute. "
807-
" Got '{}' while candidates are {}.".format(
808-
row_id_attribute,
809-
[attr[0] for attr in attributes_],
810-
),
800+
f" Got '{row_id_attribute}' while candidates are {[attr[0] for attr in attributes_]}.",
811801
)
812802

813803
if isinstance(data, pd.DataFrame):

openml/evaluations/functions.py

Lines changed: 2 additions & 4 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(

openml/extensions/sklearn/extension.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,7 @@ def flatten_all(list_):
979979
# length 2 is for {VotingClassifier.estimators,
980980
# Pipeline.steps, FeatureUnion.transformer_list}
981981
# length 3 is for ColumnTransformer
982-
msg = "Length of tuple of type {} does not match assumptions".format(
983-
sub_component_type,
984-
)
982+
msg = f"Length of tuple of type {sub_component_type} does not match assumptions"
985983
raise ValueError(msg)
986984

987985
if isinstance(sub_component, str):
@@ -1008,9 +1006,9 @@ def flatten_all(list_):
10081006

10091007
if identifier in reserved_keywords:
10101008
parent_model = f"{model.__module__}.{model.__class__.__name__}"
1011-
msg = "Found element shadowing official " "parameter for {}: {}".format(
1012-
parent_model,
1013-
identifier,
1009+
msg = (
1010+
"Found element shadowing official "
1011+
f"parameter for {parent_model}: {identifier}"
10141012
)
10151013
raise PyOpenMLError(msg)
10161014

@@ -1035,9 +1033,9 @@ def flatten_all(list_):
10351033
model=None,
10361034
)
10371035
component_reference: OrderedDict[str, str | dict] = OrderedDict()
1038-
component_reference[
1039-
"oml-python:serialized_object"
1040-
] = COMPOSITION_STEP_CONSTANT
1036+
component_reference["oml-python:serialized_object"] = (
1037+
COMPOSITION_STEP_CONSTANT
1038+
)
10411039
cr_value: dict[str, Any] = OrderedDict()
10421040
cr_value["key"] = identifier
10431041
cr_value["step_name"] = identifier
@@ -1812,10 +1810,7 @@ def _prediction_to_probabilities(
18121810
# then we need to add a column full of zeros into the probabilities
18131811
# for class 3 because the rest of the library expects that the
18141812
# probabilities are ordered the same way as the classes are ordered).
1815-
message = "Estimator only predicted for {}/{} classes!".format(
1816-
proba_y.shape[1],
1817-
len(task.class_labels),
1818-
)
1813+
message = f"Estimator only predicted for {proba_y.shape[1]}/{len(task.class_labels)} classes!"
18191814
warnings.warn(message, stacklevel=2)
18201815
openml.config.logger.warning(message)
18211816

@@ -2008,9 +2003,7 @@ def is_subcomponent_specification(values):
20082003
pass
20092004
else:
20102005
raise TypeError(
2011-
"Subcomponent flow should be of type flow, but is {}".format(
2012-
type(subcomponent_flow),
2013-
),
2006+
f"Subcomponent flow should be of type flow, but is {type(subcomponent_flow)}",
20142007
)
20152008

20162009
current = {

openml/flows/functions.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ def list_flows(
140140
tag: str | None = ...,
141141
output_format: Literal["dict"] = "dict",
142142
**kwargs: Any,
143-
) -> dict:
144-
...
143+
) -> dict: ...
145144

146145

147146
@overload
@@ -152,8 +151,7 @@ def list_flows(
152151
*,
153152
output_format: Literal["dataframe"],
154153
**kwargs: Any,
155-
) -> pd.DataFrame:
156-
...
154+
) -> pd.DataFrame: ...
157155

158156

159157
@overload
@@ -163,8 +161,7 @@ def list_flows(
163161
tag: str | None,
164162
output_format: Literal["dataframe"],
165163
**kwargs: Any,
166-
) -> pd.DataFrame:
167-
...
164+
) -> pd.DataFrame: ...
168165

169166

170167
def list_flows(
@@ -243,18 +240,15 @@ def list_flows(
243240

244241

245242
@overload
246-
def _list_flows(output_format: Literal["dict"] = ..., **kwargs: Any) -> dict:
247-
...
243+
def _list_flows(output_format: Literal["dict"] = ..., **kwargs: Any) -> dict: ...
248244

249245

250246
@overload
251-
def _list_flows(*, output_format: Literal["dataframe"], **kwargs: Any) -> pd.DataFrame:
252-
...
247+
def _list_flows(*, output_format: Literal["dataframe"], **kwargs: Any) -> pd.DataFrame: ...
253248

254249

255250
@overload
256-
def _list_flows(output_format: Literal["dataframe"], **kwargs: Any) -> pd.DataFrame:
257-
...
251+
def _list_flows(output_format: Literal["dataframe"], **kwargs: Any) -> pd.DataFrame: ...
258252

259253

260254
def _list_flows(
@@ -391,13 +385,11 @@ def get_flow_id(
391385

392386

393387
@overload
394-
def __list_flows(api_call: str, output_format: Literal["dict"] = "dict") -> dict:
395-
...
388+
def __list_flows(api_call: str, output_format: Literal["dict"] = "dict") -> dict: ...
396389

397390

398391
@overload
399-
def __list_flows(api_call: str, output_format: Literal["dataframe"]) -> pd.DataFrame:
400-
...
392+
def __list_flows(api_call: str, output_format: Literal["dataframe"]) -> pd.DataFrame: ...
401393

402394

403395
def __list_flows(

openml/runs/functions.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,9 @@ def _calculate_local_measure( # type: ignore
680680
user_defined_measures_per_fold[measure][rep_no][fold_no] = user_defined_measures_fold[
681681
measure
682682
]
683-
user_defined_measures_per_sample[measure][rep_no][fold_no][
684-
sample_no
685-
] = user_defined_measures_fold[measure]
683+
user_defined_measures_per_sample[measure][rep_no][fold_no][sample_no] = (
684+
user_defined_measures_fold[measure]
685+
)
686686

687687
trace: OpenMLRunTrace | None = None
688688
if len(traces) > 0:
@@ -784,13 +784,7 @@ def _run_task_get_arffcontent_parallel_helper( # noqa: PLR0913
784784
raise NotImplementedError(task.task_type)
785785

786786
config.logger.info(
787-
"Going to run model {} on dataset {} for repeat {} fold {} sample {}".format(
788-
str(model),
789-
openml.datasets.get_dataset(task.dataset_id).name,
790-
rep_no,
791-
fold_no,
792-
sample_no,
793-
),
787+
f"Going to run model {model!s} on dataset {openml.datasets.get_dataset(task.dataset_id).name} for repeat {rep_no} fold {fold_no} sample {sample_no}",
794788
)
795789
(
796790
pred_y,

openml/runs/trace.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,7 @@ def merge_traces(cls, traces: list[OpenMLRunTrace]) -> OpenMLRunTrace:
504504
if list(param_keys) != list(trace_itr_keys):
505505
raise ValueError(
506506
"Cannot merge traces because the parameters are not equal: "
507-
"{} vs {}".format(
508-
list(trace_itr.parameters.keys()),
509-
list(iteration.parameters.keys()),
510-
),
507+
f"{list(trace_itr.parameters.keys())} vs {list(iteration.parameters.keys())}",
511508
)
512509

513510
if key in merged_trace:
@@ -521,10 +518,7 @@ def merge_traces(cls, traces: list[OpenMLRunTrace]) -> OpenMLRunTrace:
521518
return cls(None, merged_trace)
522519

523520
def __repr__(self) -> str:
524-
return "[Run id: {}, {} trace iterations]".format(
525-
-1 if self.run_id is None else self.run_id,
526-
len(self.trace_iterations),
527-
)
521+
return f"[Run id: {-1 if self.run_id is None else self.run_id}, {len(self.trace_iterations)} trace iterations]"
528522

529523
def __iter__(self) -> Iterator[OpenMLTraceIteration]:
530524
yield from self.trace_iterations.values()

0 commit comments

Comments
 (0)