Skip to content

Commit 7cd93fa

Browse files
committed
ruff and mypy fixes
1 parent e873e0b commit 7cd93fa

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/pynxtools/dataconverter/validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def best_namefit_of(
218218

219219

220220
def is_valid_unit_for_node(
221-
node: NexusNode, unit: str, unit_path: str, hints: Dict[str, Any]
221+
node: NexusNode, unit: str, unit_path: str, hints: dict[str, Any]
222222
) -> None:
223223
"""
224224
Validate whether a unit string is compatible with the expected unit category for a given NeXus node.
@@ -233,14 +233,14 @@ def is_valid_unit_for_node(
233233
node (NexusNode): The node containing unit metadata to validate against.
234234
unit (str): The unit string to validate (e.g., "m", "eV", "1", "").
235235
unit_path (str): The path to the unit in the NeXus template, used for logging.
236-
hints (Dict[str, Any]): Additional metadata used during validation. For example,
236+
hints (dict[str, Any]): Additional metadata used during validation. For example,
237237
hints["transformation_type"] may be used to determine the expected unit category
238238
if the node represents a transformation.
239239
"""
240240
# Need to use a list as `NXtransformation` is a special use case
241241
if node.unit == "NX_TRANSFORMATION":
242242
if (transformation_type := hints.get("transformation_type")) is not None:
243-
category_map: Dict[str, str] = {
243+
category_map: dict[str, str] = {
244244
"translation": "NX_LENGTH",
245245
"rotation": "NX_ANGLE",
246246
}

src/pynxtools/nomad/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
) from exc
8282

8383
from pynxtools import NX_DOC_BASES, get_definitions_url
84-
from pynxtools.units import NXUnitSet, ureg
8584
from pynxtools.definitions.dev_tools.utils.nxdl_utils import get_nexus_definitions_path
8685
from pynxtools.nomad.utils import (
8786
FIELD_STATISTICS,
@@ -90,6 +89,7 @@
9089
_rename_nx_for_nomad,
9190
get_quantity_base_name,
9291
)
92+
from pynxtools.units import NXUnitSet, ureg
9393

9494
# URL_REGEXP from
9595
# https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url

src/pynxtools/units/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
"""A unit registry for NeXus units"""
1919

2020
import os
21-
from typing import Optional, Dict, Any
21+
from typing import Any, Optional
22+
2223
from pint import UnitRegistry
23-
from pint.errors import UndefinedUnitError, DefinitionSyntaxError, DimensionalityError
24+
from pint.errors import DefinitionSyntaxError, DimensionalityError, UndefinedUnitError
2425

2526
try:
2627
from nomad.units import ureg
@@ -37,7 +38,7 @@ class NXUnitSet:
3738
- 'transformation' -> specially handled elsewhere
3839
"""
3940

40-
mapping: Dict[str, Optional[str]] = {
41+
mapping: dict[str, Optional[str]] = {
4142
"NX_ANGLE": "[angle]",
4243
"NX_ANY": None,
4344
"NX_AREA": "[area]",
@@ -73,7 +74,7 @@ class NXUnitSet:
7374
"NX_WAVENUMBER": "1 / [length]",
7475
}
7576

76-
_dimensionalities: Dict[str, Optional[Any]] = {}
77+
_dimensionalities: dict[str, Optional[Any]] = {}
7778

7879
@classmethod
7980
def get_dimensionality(cls, nx_unit: str) -> Optional[Any]:

0 commit comments

Comments
 (0)