Skip to content

Commit b4e8b82

Browse files
lukaspielukaspie
andauthored
bump ruff and mypy (#733)
Co-authored-by: lukaspie <lukaspie@github.com>
1 parent fe45673 commit b4e8b82

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.14.0
3+
rev: v0.15.0
44
hooks:
55
- id: ruff-check
66
files: ^(src/pynxtools|tests)/.*\.py$
77
- id: ruff-format
88
files: ^(src/pynxtools|tests)/.*\.py$
99

1010
- repo: https://github.com/pre-commit/mirrors-mypy
11-
rev: v1.18.1
11+
rev: v1.19.1
1212
hooks:
1313
- id: mypy # static type checking
1414

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ docs = [
5858
]
5959
dev = [
6060
"mypy",
61-
"ruff>=0.14.0",
61+
"ruff>=0.15.0",
6262
"pytest",
6363
"pytest-timeout",
6464
"pytest-cov",

src/pynxtools/dataconverter/helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def _log(self, path: str, log_type: ValidationProblem, value: Any | None, *args)
201201
elif log_type == ValidationProblem.ExpectedField:
202202
logger.error(f"Expected a field at {path}, but found a group.")
203203
elif log_type == ValidationProblem.MissingDocumentation:
204-
if "@" in path.rsplit("/")[-1]:
204+
if "@" in path.rsplit("/", maxsplit=1)[-1]:
205205
logger.warning(f"Attribute {path} has no documentation.")
206206
else:
207207
logger.warning(f"Field {path} has no documentation.")
@@ -901,8 +901,8 @@ def get_custom_attr_path(path: str) -> str:
901901
Returns:
902902
str: The modified path string representing the custom attribute path.
903903
"""
904-
if path.split("/")[-1].startswith("@"):
905-
attr_name = path.split("/")[-1][1:] # remove "@"
904+
if path.rsplit("/", maxsplit=1)[-1].startswith("@"):
905+
attr_name = path.rsplit("/", maxsplit=1)[-1][1:] # remove "@"
906906
return f"{path}_custom"
907907
return f"{path}/@custom"
908908

src/pynxtools/dataconverter/validation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,11 @@ def is_documented(key: str, tree: NexusNode) -> bool:
15981598
node = add_best_matches_for(key, tree, check_types=True)
15991599
except TypeError:
16001600
node = None
1601-
nx_type = "attribute" if key.split("/")[-1].startswith("@") else "field"
1601+
nx_type = (
1602+
"attribute"
1603+
if key.rsplit("/", maxsplit=1)[-1].startswith("@")
1604+
else "field"
1605+
)
16021606

16031607
collector.collect_and_log(
16041608
key,

src/pynxtools/nexus/nexus.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def decode_if_string(
6666
# may need to be updated in the future: https://api.h5py.org/h5t.html
6767
if elem.dtype.kind == "S": # Check if it's a bytes array (fixed-length strings)
6868
decoded_array = np.vectorize(
69-
lambda x: x.decode(encoding).rstrip("\x00")
70-
if isinstance(x, bytes)
71-
else x
69+
lambda x: (
70+
x.decode(encoding).rstrip("\x00") if isinstance(x, bytes) else x
71+
)
7272
)(elem)
7373
return decoded_array.astype(str) # Ensure the dtype is str
7474

tests/dataconverter/test_nexus_tree.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def test_correct_extension_of_tree():
4343
def get_node_fields(tree: NexusNode) -> list[tuple[str, Any]]:
4444
return list(
4545
filter(
46-
lambda x: not x[0].startswith("_")
47-
and x[0] not in ("inheritance", "is_a", "parent_of", "nxdl_base"),
46+
lambda x: (
47+
not x[0].startswith("_")
48+
and x[0] not in ("inheritance", "is_a", "parent_of", "nxdl_base")
49+
),
4850
tree.__dict__.items(),
4951
)
5052
)

0 commit comments

Comments
 (0)