From b9dc9693d789a9fb4cf62ce6e6ec04403457f1b9 Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Tue, 17 Sep 2024 11:17:17 +0200 Subject: [PATCH] fix linted warnings --- python/edm4hep/__init__.py | 4 ++-- scripts/createEDM4hepFile.py | 3 ++- scripts/updateReadmeLinks.py | 14 +++++++++----- test/conftest.py | 2 +- test/utils/test_kinematics.py | 2 -- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/python/edm4hep/__init__.py b/python/edm4hep/__init__.py index 98048ff87..8880cdf59 100644 --- a/python/edm4hep/__init__.py +++ b/python/edm4hep/__init__.py @@ -24,9 +24,9 @@ res = ROOT.gInterpreter.LoadFile("edm4hep/Constants.h") if res != 0: raise RuntimeError("Failed to load Constants.h") -from ROOT import edm4hep +from ROOT import edm4hep # noqa: E402 -from podio.pythonizations import load_pythonizations +from podio.pythonizations import load_pythonizations # noqa: E402 load_pythonizations("edm4hep") diff --git a/scripts/createEDM4hepFile.py b/scripts/createEDM4hepFile.py index b532e174c..1ab26c742 100755 --- a/scripts/createEDM4hepFile.py +++ b/scripts/createEDM4hepFile.py @@ -135,7 +135,8 @@ def create_CovMatrixNf(n_dim): """Create a covariance matrix of dimension n_dim""" if n_dim not in (2, 3, 4, 6): return ValueError( - f"{n_dim} is not a valid dimension for a CovMatrix in EDM4hep. Valid: (2, 3, 4, 6)" + f"{n_dim} is not a valid dimension for a CovMatrix in EDM4hep. " + "Valid: (2, 3, 4, 6)" ) counter = count(COUNT_START) # With the current version of cppyy (from ROOT 6.30.06) diff --git a/scripts/updateReadmeLinks.py b/scripts/updateReadmeLinks.py index 232d6ae88..ae858ab62 100755 --- a/scripts/updateReadmeLinks.py +++ b/scripts/updateReadmeLinks.py @@ -25,9 +25,10 @@ def check_readme_links(): new_readme_content = "" links_are_ok = True - for readme_line in readme_content: + for line in readme_content: + readme_line = line edm4hep_objects = re.findall( - "\[(.*?)\]\(https:\/\/github.com\/key4hep\/EDM4hep\/blob\/main\/edm4hep\.yaml#L(\d+?)\)", + r"\[(.*?)\]\(https:\/\/github.com\/key4hep\/EDM4hep\/blob\/main\/edm4hep\.yaml#L(\d+?)\)", readme_line, ) if edm4hep_objects: @@ -41,7 +42,9 @@ def check_readme_links(): ] if len(edm4hep_yaml_line_numbers_with_match) != 1: print( - f"Error: failed to replace line number for {edm4hep_object}, either no or several matches were found in edm4hep.yaml with the regex '{regex}'" + f"Error: failed to replace line number for {edm4hep_object}, " + f"either no or several matches were found in edm4hep.yaml " + f"with the regex '{regex}'" ) sys.exit(1) if edm4hep_yaml_line_numbers_with_match[0] != original_line_number: @@ -51,7 +54,7 @@ def check_readme_links(): f"[{edm4hep_object}](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L{edm4hep_yaml_line_numbers_with_match[0]})", ) print( - f"{edm4hep_object} is wrongly linked (line {original_line_number} --> {edm4hep_yaml_line_numbers_with_match[0]})" + f"{edm4hep_object} is wrongly linked (line {original_line_number} --> {edm4hep_yaml_line_numbers_with_match[0]})" # noqa: E501 ) new_readme_content += readme_line return links_are_ok, new_readme_content @@ -67,6 +70,7 @@ def check_readme_links(): print("README.md links updated.") else: print( - "README.md links should be updated. (Run ./scripts/updateReadmeLinks.py to fix them)" + "README.md links should be updated. " + "(Run ./scripts/updateReadmeLinks.py to fix them)" ) sys.exit(1) diff --git a/test/conftest.py b/test/conftest.py index 228cc9be1..d56bd388a 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -14,5 +14,5 @@ def pytest_addoption(parser): def pytest_configure(config): """This is a slighty hacky solution to make the pytest configuration available in test modules outside of fixtures""" - global options + global options # noqa: PLW0603 options = config.option diff --git a/test/utils/test_kinematics.py b/test/utils/test_kinematics.py index 4cdbc889e..a5c394290 100644 --- a/test/utils/test_kinematics.py +++ b/test/utils/test_kinematics.py @@ -1,8 +1,6 @@ #!/usr/bin/env python3 import unittest -import cppyy - import edm4hep # A few shorthands for slightly easier to read tests below