Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
GinzburgLev committed Jan 16, 2025
1 parent ea3358a commit 4a0c34c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/pynxtools/dataconverter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ def _log(self, path: str, log_type: ValidationProblem, value: Optional[Any], *ar

if log_type == ValidationProblem.UnitWithoutDocumentation:
logger.warning(
f"The unit, {path} = {value}, "
"is being written but has no documentation"
f"The unit, {path} = {value}, is being written but has no documentation"
)
elif log_type == ValidationProblem.InvalidEnum:
logger.warning(
f"The value at {path} should be on of the "
f"following strings: {value}"
f"The value at {path} should be on of the following strings: {value}"
)
elif log_type == ValidationProblem.MissingRequiredGroup:
logger.warning(f"The required group, {path}, hasn't been supplied.")
Expand Down Expand Up @@ -344,7 +342,7 @@ def get_all_defined_required_children_for_elem(xml_element):
list_of_children_to_add.add(f"{name_to_add}/@units")
elif tag == "group":
nxdlpath = (
f'{xml_element.get("nxdlpath")}/{get_nxdl_name_from_elem(child)}'
f"{xml_element.get('nxdlpath')}/{get_nxdl_name_from_elem(child)}"
)
nxdlbase = xml_element.get("nxdlbase")
nx_name = nxdlbase[nxdlbase.rfind("/") + 1 : nxdlbase.rfind(".nxdl")]
Expand Down Expand Up @@ -696,15 +694,15 @@ def is_valid_data_field(value, nxdl_type, path):
(if conversion is not needed or impossible)
"""
accepted_types = NEXUS_TO_PYTHON_DATA_TYPES[nxdl_type]
output_value=value
output_value = value

if not isinstance(value, dict) and not is_valid_data_type(value, accepted_types):
try:
if accepted_types[0] is bool and isinstance(value, str):
value = convert_str_to_bool_safe(value)
if value is None:
raise ValueError
output_value=accepted_types[0](value)
output_value = accepted_types[0](value)
except ValueError:
collector.collect_and_log(
path, ValidationProblem.InvalidType, accepted_types, nxdl_type
Expand Down

0 comments on commit 4a0c34c

Please sign in to comment.