From f1658003faf0f84b2c8551c079126b8737e41ede Mon Sep 17 00:00:00 2001 From: Clemens Lange Date: Fri, 4 Oct 2024 18:01:15 +0200 Subject: [PATCH 1/2] Require named arguments to fix pylint too-many-positional-arguments --- hepdata_lib/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hepdata_lib/__init__.py b/hepdata_lib/__init__.py index 2613a81..c1fc9f8 100644 --- a/hepdata_lib/__init__.py +++ b/hepdata_lib/__init__.py @@ -55,7 +55,7 @@ def __init__(self): self.files_to_copy = [] self.additional_resources = [] - def add_additional_resource(self, description, location, copy_file=False, file_type=None, + def add_additional_resource(self, description, location, *, copy_file=False, file_type=None, resource_license=None): """ Add any kind of additional resource. @@ -143,7 +143,7 @@ class Variable: # pylint: disable=too-many-instance-attributes # Eight is reasonable in this case. - def __init__(self, name, is_independent=True, is_binned=True, units="", values=None, + def __init__(self, name, *, is_independent=True, is_binned=True, units="", values=None, zero_uncertainties_warning=True): # pylint: disable=too-many-arguments self.name = name From ab46b9df2076d829ee3951e7f07a92d3539d62cd Mon Sep 17 00:00:00 2001 From: Clemens Lange Date: Mon, 7 Oct 2024 16:21:04 +0200 Subject: [PATCH 2/2] Fix pylint failures for tests (too-many-function-args) --- tests/test_submission.py | 2 +- tests/test_table.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_submission.py b/tests/test_submission.py index 6bee2c0..8a9373c 100644 --- a/tests/test_submission.py +++ b/tests/test_submission.py @@ -157,7 +157,7 @@ def test_nested_files_to_copy(self): # Add resource to table, add table to Submission sub = Submission() tab = Table('test') - tab.add_additional_resource("a_resource",testfile,True) + tab.add_additional_resource("a_resource",testfile, copy_file=True) sub.add_table(tab) # Write outputs diff --git a/tests/test_table.py b/tests/test_table.py index 1fa434f..fd06d81 100644 --- a/tests/test_table.py +++ b/tests/test_table.py @@ -265,7 +265,10 @@ def test_add_additional_resource_license_check(self): some_pdf = f"{os.path.dirname(__file__)}/minimal.pdf" # Set default description, location, copy_file and file_type arguments for a resource file - resource_args = ["Description", some_pdf, True, "Type"] + description = "Description" + location = some_pdf + copy_file = True + file_type = "Type" for data in license_data: # If error is expected, we check for the error @@ -273,14 +276,14 @@ def test_add_additional_resource_license_check(self): if data["error"]: with self.assertRaises(ValueError): test_table.add_additional_resource( - *resource_args, + description, location, copy_file=copy_file, file_type=file_type, resource_license=data["license_data"] ) else: # Check for lack of failure try: test_table.add_additional_resource( - *resource_args, + description, location, copy_file=copy_file, file_type=file_type, resource_license=data["license_data"] ) except ValueError: