Skip to content

Commit 1ec8123

Browse files
authored
Merge pull request #1015 from PowerGridModel/fix/mypy-version
Fix nightly: mypy version bump + github actions report failing
2 parents 2b4181a + 76eafa5 commit 1ec8123

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ jobs:
5858
ci-passed:
5959
runs-on: ubuntu-latest
6060
needs: [ci-started, build-test-release, check-code-quality, reuse-compliance, clang-tidy]
61+
if: always()
6162

6263
steps:
64+
# this explicit check is needed cfr. https://github.com/orgs/community/discussions/75568
65+
- name: "Check whether all jobs passed"
66+
run: echo '${{ toJSON(needs) }}' | jq -e 'to_entries | all(.value.result == "success")'
6367
- run: echo "ci passed"
6468

6569
publish:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
# Run the formatter.
1717
- id: ruff-format
1818
- repo: https://github.com/pre-commit/mirrors-mypy
19-
rev: v1.13.0
19+
rev: v1.16.0
2020
hooks:
2121
- id: mypy
2222
additional_dependencies:

src/power_grid_model/_core/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def convert_single_dataset_to_python_single_dataset(
364364
# For example: {"node": [{"id": 0, ...}, {"id": 1, ...}], "line": [{"id": 2, ...}]}
365365
def _convert_component(objects: SingleComponentData):
366366
# This should be a single data set
367-
if not isinstance(objects, np.ndarray) or objects.ndim != 1:
367+
if not isinstance(objects, np.ndarray) or objects.ndim != 1 or objects.dtype.names is None:
368368
raise ValueError("Invalid data format")
369369

370370
return [
@@ -441,6 +441,8 @@ def _convert_data_to_row_or_columnar(
441441
return {}
442442
if isinstance(attrs, ComponentAttributeFilterOptions):
443443
names = cast(SingleArray, data).dtype.names if not is_columnar(data) else cast(SingleColumnarData, data).keys()
444+
if names is None:
445+
raise ValueError("No attributes available in meta")
444446
return {attr: deepcopy(data[attr]) for attr in names}
445447
return {attr: deepcopy(data[attr]) for attr in attrs}
446448

src/power_grid_model/validation/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ def _eval_field_expression(data: np.ndarray, expression: str) -> np.ndarray:
6969
'foo/bar' -> data['foo'] / data['bar']
7070
7171
"""
72-
7372
# Validate the expression
7473
match = re.fullmatch(r"[a-z][a-z0-9_]*(\s*/\s*[a-z][a-z0-9_]*)?", expression)
7574
if not match:
7675
raise ValueError(f"Invalid field expression '{expression}'")
7776

77+
if data.dtype.names is None:
78+
raise ValueError("No attributes available in meta")
79+
7880
# Find all field names and check if they exist in the dataset
7981
fields = [f.strip() for f in expression.split("/")]
8082
for field in fields:
@@ -124,6 +126,9 @@ def _update_component_array_data(
124126
Update the data in a numpy array, with another numpy array,
125127
indexed on the "id" field and only non-NaN values are overwritten.
126128
"""
129+
if update_data.dtype.names is None:
130+
raise ValueError("Invalid data format")
131+
127132
optional_ids_active = (
128133
"id" in update_data.dtype.names
129134
and np.all(update_data["id"] == np.iinfo(update_data["id"].dtype).min)

tests/unit/test_serialization.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ def assert_almost_equal(value: np.ndarray, reference: Any):
455455
assert_almost_equal(v, r)
456456
elif isinstance(reference, dict):
457457
assert len(value) == len(reference)
458+
assert value.dtype.names is not None
458459
for attribute in value.dtype.names:
459460
if attribute in reference:
460461
assert_almost_equal(value[attribute], reference[attribute])

0 commit comments

Comments
 (0)