Skip to content

Commit f5208b9

Browse files
committed
Apply changes from ruff
1 parent f442d20 commit f5208b9

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

abcd/backends/atoms_opensearch.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,7 @@ def delete_property(self, name: str, query: dict | str | None = None):
940940

941941
self.client.update_by_query(index=self.index_name, body=body)
942942

943-
def hist(
944-
self, name: str, query: dict | str | None = None, **kwargs
945-
) -> dict | None:
943+
def hist(self, name: str, query: dict | str | None = None, **kwargs) -> dict | None:
946944
"""
947945
Calculate histogram statistics for a property from all matching documents.
948946

abcd/backends/atoms_properties.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ def __init__(
8484
self.encoding = encoding
8585
try:
8686
self.df = pd.read_csv(self.data_file, encoding=self.encoding)
87-
except UnicodeDecodeError:
87+
except UnicodeDecodeError as err:
8888
detected = chardet.detect(Path(self.data_file).read_bytes())
8989
raise ValueError(
9090
f"File cannot be decoded using encoding: {self.encoding}."
9191
f" Detected encoding: {detected}."
92-
)
92+
) from err
9393
except pd.errors.ParserError:
9494
self.df = pd.read_excel(self.data_file, header=0)
9595

@@ -154,11 +154,11 @@ def set_struct_files(self):
154154
for i in range(len(self.df)):
155155
try:
156156
struct_name = self.df.iloc[i][self.struct_name_label]
157-
except KeyError:
157+
except KeyError as err:
158158
raise ValueError(
159159
f"{self.struct_name_label} is not a valid column in "
160160
"the data loaded."
161-
)
161+
) from err
162162
struct_file = self.get_struct_file(struct_name)
163163
self.struct_files.append(struct_file)
164164

abcd/backends/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ def histogram(name, data, **kwargs):
1919
print("Mixed type error of the %s property!", name)
2020
return None
2121

22-
if ptype == float:
22+
if isinstance(data[0], float):
2323
bins = kwargs.get("bins", 10)
2424
return _hist_float(name, data, bins)
2525

26-
if ptype == int:
26+
if isinstance(data[0], int):
2727
bins = kwargs.get("bins", 10)
2828
return _hist_int(name, data, bins)
2929

30-
if ptype == str:
30+
if isinstance(data[0], str):
3131
return _hist_str(name, data, **kwargs)
3232

33-
if ptype == datetime:
33+
if isinstance(data[0], datetime):
3434
bins = kwargs.get("bins", 10)
3535
return _hist_date(name, data, bins)
3636

tests/test_opensearch_mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_create(self, abcd):
5656
abcd.destroy()
5757
abcd.create()
5858
assert abcd.client.indices.exists("test_index") is True
59-
abcd.client.indices.exists("fake_index") is False
59+
assert abcd.client.indices.exists("fake_index") is False
6060

6161
def test_push(self, abcd):
6262
"""

0 commit comments

Comments
 (0)