Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require named arguments to fix pylint too-many-positional-arguments #273

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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