Skip to content

Commit

Permalink
Require named arguments to fix pylint too-many-positional-arguments (#…
Browse files Browse the repository at this point in the history
…273)

* Require named arguments to fix pylint too-many-positional-arguments

* Fix pylint failures for tests (too-many-function-args)
  • Loading branch information
clelange authored Oct 9, 2024
1 parent 79091d0 commit bd71273
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hepdata_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,22 +265,25 @@ 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
# Otherwise, just add and check length later
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:
Expand Down

0 comments on commit bd71273

Please sign in to comment.