From 12d00ab4fd8c06957dabf1cbf7e785c1826f755e Mon Sep 17 00:00:00 2001 From: domna Date: Mon, 3 Jul 2023 11:13:56 +0200 Subject: [PATCH 1/2] Fixes linting --- pynxtools/nexus/nexus.py | 12 ++++++------ pynxtools/nexus/nxdl_utils.py | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pynxtools/nexus/nexus.py b/pynxtools/nexus/nexus.py index 600d7ef5c..db9631c11 100644 --- a/pynxtools/nexus/nexus.py +++ b/pynxtools/nexus/nexus.py @@ -196,8 +196,8 @@ def get_nxdl_doc(hdf_info, logger, doc, attr=False): # new way: retrieve multiple inherited base classes (class_path, nxdl_path, elist) = \ get_inherited_hdf_nodes(nx_name=get_nxdl_entry(hdf_info), hdf_node=hdf_node, - hdf_path=hdf_info['hdf_path'] if 'hdf_path' in hdf_info else None, - hdf_root=hdf_info['hdf_root'] if 'hdf_root' in hdf_info else None) + hdf_path=hdf_info['hdf_path'] if 'hdf_path' in hdf_info else None, + hdf_root=hdf_info['hdf_root'] if 'hdf_root' in hdf_info else None) elem = elist[0] if class_path and elist else None if doc: logger.debug("classpath: " + str(class_path)) @@ -259,8 +259,8 @@ def get_hdf_path(hdf_info): @lru_cache(maxsize=None) -def get_inherited_hdf_nodes(nx_name: str = None, elem: ET.Element = None,# pylint: disable=too-many-arguments,too-many-locals - hdf_node=None, hdf_path=None, hdf_root=None, attr=False): +def get_inherited_hdf_nodes(nx_name: str = None, elem: ET.Element = None, # pylint: disable=too-many-arguments,too-many-locals + hdf_node=None, hdf_path=None, hdf_root=None, attr=False): """Returns a list of ET.Element for the given path.""" # let us start with the given definition file if hdf_node is None: @@ -541,8 +541,8 @@ def get_all_is_a_rel_from_hdf_node(hdf_node, hdf_path): hdf_info = {'hdf_path': hdf_path, 'hdf_node': hdf_node} (_, _, elist) = \ get_inherited_hdf_nodes(nx_name=get_nxdl_entry(hdf_info), hdf_node=hdf_node, - hdf_path=hdf_info['hdf_path'] if 'hdf_path' in hdf_info else None, - hdf_root=hdf_info['hdf_root'] if 'hdf_root' in hdf_info else None) + hdf_path=hdf_info['hdf_path'] if 'hdf_path' in hdf_info else None, + hdf_root=hdf_info['hdf_root'] if 'hdf_root' in hdf_info else None) return elist diff --git a/pynxtools/nexus/nxdl_utils.py b/pynxtools/nexus/nxdl_utils.py index b3211891a..52b60728f 100644 --- a/pynxtools/nexus/nxdl_utils.py +++ b/pynxtools/nexus/nxdl_utils.py @@ -373,6 +373,7 @@ def get_required_string(nxdl_elem): return "<>" return "<>" + # below there are some functions used in get_nxdl_doc function: def write_doc_string(logger, doc, attr): """Simple function that prints a line in the logger if doc exists""" @@ -671,7 +672,6 @@ def walk_elist(elist, html_name): return elist, html_name - @lru_cache(maxsize=None) def get_inherited_nodes(nxdl_path: str = None, # pylint: disable=too-many-arguments,too-many-locals nx_name: str = None, elem: ET.Element = None, @@ -717,4 +717,3 @@ def get_node_at_nxdl_path(nxdl_path: str = None, raise NxdlAttributeError(f"Attributes were not found for {nxdl_path}. " "Please check this entry in the template dictionary.") return elem - From 32b16f004f07ac97a9c5a4e7cf97eff48384c769 Mon Sep 17 00:00:00 2001 From: domna Date: Mon, 3 Jul 2023 11:40:31 +0200 Subject: [PATCH 2/2] Fixes more linting and disabling a lot --- pynxtools/dataconverter/helpers.py | 4 ++-- pynxtools/nexus/nexus.py | 2 +- pynxtools/nexus/nxdl_utils.py | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pynxtools/dataconverter/helpers.py b/pynxtools/dataconverter/helpers.py index 337dffb57..75a2bc2b9 100644 --- a/pynxtools/dataconverter/helpers.py +++ b/pynxtools/dataconverter/helpers.py @@ -75,8 +75,8 @@ def get_all_defined_required_children_for_elem(xml_element): visited_paths.append(nxdlpath) children = get_all_defined_required_children(nxdlpath, nx_name) further_children = set() - for child in children: - further_children.add(f"{name_to_add}/{child}") + for further_child in children: + further_children.add(f"{name_to_add}/{further_child}") list_of_children_to_add.update(further_children) return list_of_children_to_add diff --git a/pynxtools/nexus/nexus.py b/pynxtools/nexus/nexus.py index db9631c11..9afa711fb 100644 --- a/pynxtools/nexus/nexus.py +++ b/pynxtools/nexus/nexus.py @@ -9,7 +9,7 @@ import h5py import click -from .nxdl_utils import * +from pynxtools.nexus.nxdl_utils import * # pylint: disable=wildcard-import, unused-wildcard-import def get_nxdl_entry(hdf_info): diff --git a/pynxtools/nexus/nxdl_utils.py b/pynxtools/nexus/nxdl_utils.py index 52b60728f..706390a7c 100644 --- a/pynxtools/nexus/nxdl_utils.py +++ b/pynxtools/nexus/nxdl_utils.py @@ -6,8 +6,6 @@ import xml.etree.ElementTree as ET from functools import lru_cache from glob import glob -import sys -import logging import textwrap @@ -675,7 +673,7 @@ def walk_elist(elist, html_name): @lru_cache(maxsize=None) def get_inherited_nodes(nxdl_path: str = None, # pylint: disable=too-many-arguments,too-many-locals nx_name: str = None, elem: ET.Element = None, - attr=False): + attr=False): # pylint: disable=unused-argument """Returns a list of ET.Element for the given path.""" # let us start with the given definition file elist = [] # type: ignore[var-annotated] @@ -687,6 +685,7 @@ def get_inherited_nodes(nxdl_path: str = None, # pylint: disable=too-many-argum path = html_path for pind in range(len(path)): html_name = html_path[pind] + # pylint: disable=duplicate-code elist, html_name = walk_elist(elist, html_name) if elist: class_path.append(get_nx_class(elist[0]))