Skip to content

Commit 1d7fbda

Browse files
authored
Merge pull request #1271 from openml/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2 parents d26a911 + 4b0ec45 commit 1d7fbda

11 files changed

Lines changed: 19 additions & 15 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 23.3.0
3+
rev: 23.7.0
44
hooks:
55
- id: black
66
args: [--line-length=100]
@@ -28,7 +28,7 @@ repos:
2828
args: [ --disallow-untyped-defs, --disallow-any-generics,
2929
--disallow-any-explicit, --implicit-optional ]
3030
- repo: https://github.com/pycqa/flake8
31-
rev: 6.0.0
31+
rev: 6.1.0
3232
hooks:
3333
- id: flake8
3434
name: flake8 openml

openml/datasets/data_feature.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class OpenMLDataFeature(object):
1818
nominal_values : list(str)
1919
list of the possible values, in case of nominal attribute
2020
number_missing_values : int
21+
Number of rows that have a missing value for this feature.
2122
"""
2223

2324
LEGAL_DATA_TYPES = ["nominal", "numeric", "string", "date"]
@@ -30,8 +31,8 @@ def __init__(
3031
nominal_values: List[str],
3132
number_missing_values: int,
3233
):
33-
if type(index) != int:
34-
raise ValueError("Index is of wrong datatype")
34+
if not isinstance(index, int):
35+
raise TypeError(f"Index must be `int` but is {type(index)}")
3536
if data_type not in self.LEGAL_DATA_TYPES:
3637
raise ValueError(
3738
"data type should be in %s, found: %s" % (str(self.LEGAL_DATA_TYPES), data_type)
@@ -50,8 +51,9 @@ def __init__(
5051
else:
5152
if nominal_values is not None:
5253
raise TypeError("Argument `nominal_values` must be None for non-nominal feature.")
53-
if type(number_missing_values) != int:
54-
raise ValueError("number_missing_values is of wrong datatype")
54+
if not isinstance(number_missing_values, int):
55+
msg = f"number_missing_values must be int but is {type(number_missing_values)}"
56+
raise TypeError(msg)
5557

5658
self.index = index
5759
self.name = str(name)

openml/datasets/functions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ def __list_datasets(api_call, output_format="dict"):
192192
datasets_dict = xmltodict.parse(xml_string, force_list=("oml:dataset",))
193193

194194
# Minimalistic check if the XML is useful
195-
assert type(datasets_dict["oml:data"]["oml:dataset"]) == list, type(datasets_dict["oml:data"])
195+
assert isinstance(datasets_dict["oml:data"]["oml:dataset"], list), type(
196+
datasets_dict["oml:data"]
197+
)
196198
assert datasets_dict["oml:data"]["@xmlns:oml"] == "http://openml.org/openml", datasets_dict[
197199
"oml:data"
198200
]["@xmlns:oml"]

openml/evaluations/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def __list_evaluations(api_call, output_format="object"):
197197
"Error in return XML, does not contain " '"oml:evaluations": %s' % str(evals_dict)
198198
)
199199

200-
assert type(evals_dict["oml:evaluations"]["oml:evaluation"]) == list, type(
200+
assert isinstance(evals_dict["oml:evaluations"]["oml:evaluation"], list), type(
201201
evals_dict["oml:evaluations"]
202202
)
203203

openml/flows/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def __list_flows(api_call: str, output_format: str = "dict") -> Union[Dict, pd.D
341341
flows_dict = xmltodict.parse(xml_string, force_list=("oml:flow",))
342342

343343
# Minimalistic check if the XML is useful
344-
assert type(flows_dict["oml:flows"]["oml:flow"]) == list, type(flows_dict["oml:flows"])
344+
assert isinstance(flows_dict["oml:flows"]["oml:flow"], list), type(flows_dict["oml:flows"])
345345
assert flows_dict["oml:flows"]["@xmlns:oml"] == "http://openml.org/openml", flows_dict[
346346
"oml:flows"
347347
]["@xmlns:oml"]

openml/runs/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ def __list_runs(api_call, output_format="dict"):
11391139
'"http://openml.org/openml": %s' % str(runs_dict)
11401140
)
11411141

1142-
assert type(runs_dict["oml:runs"]["oml:run"]) == list, type(runs_dict["oml:runs"])
1142+
assert isinstance(runs_dict["oml:runs"]["oml:run"], list), type(runs_dict["oml:runs"])
11431143

11441144
runs = OrderedDict()
11451145
for run_ in runs_dict["oml:runs"]["oml:run"]:

openml/setups/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def __list_setups(api_call, output_format="object"):
220220
'"%s": %s' % (openml_uri, str(setups_dict))
221221
)
222222

223-
assert type(setups_dict["oml:setups"]["oml:setup"]) == list, type(setups_dict["oml:setups"])
223+
assert isinstance(setups_dict["oml:setups"]["oml:setup"], list), type(setups_dict["oml:setups"])
224224

225225
setups = dict()
226226
for setup_ in setups_dict["oml:setups"]["oml:setup"]:

openml/study/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def __list_studies(api_call, output_format="object") -> Union[Dict, pd.DataFrame
595595
study_dict = xmltodict.parse(xml_string, force_list=("oml:study",))
596596

597597
# Minimalistic check if the XML is useful
598-
assert type(study_dict["oml:study_list"]["oml:study"]) == list, type(
598+
assert isinstance(study_dict["oml:study_list"]["oml:study"], list), type(
599599
study_dict["oml:study_list"]
600600
)
601601
assert study_dict["oml:study_list"]["@xmlns:oml"] == "http://openml.org/openml", study_dict[

openml/tasks/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def __list_tasks(api_call, output_format="dict"):
246246
'"http://openml.org/openml": %s' % str(tasks_dict)
247247
)
248248

249-
assert type(tasks_dict["oml:tasks"]["oml:task"]) == list, type(tasks_dict["oml:tasks"])
249+
assert isinstance(tasks_dict["oml:tasks"]["oml:task"], list), type(tasks_dict["oml:tasks"])
250250

251251
tasks = dict()
252252
procs = _get_estimation_procedure_list()

openml/tasks/split.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, name, description, split):
4343

4444
def __eq__(self, other):
4545
if (
46-
type(self) != type(other)
46+
(not isinstance(self, type(other)))
4747
or self.name != other.name
4848
or self.description != other.description
4949
or self.split.keys() != other.split.keys()

0 commit comments

Comments
 (0)