-
Notifications
You must be signed in to change notification settings - Fork 22
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
fix: Add missing comma in LHEInit fieldnames #282
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #282 +/- ##
=======================================
Coverage 91.87% 91.87%
=======================================
Files 2 2
Lines 320 320
Branches 64 64
=======================================
Hits 294 294
Misses 17 17
Partials 9 9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Here's what we could do. But it seems a bit unnecessary unless we want to restrict the access to the predefined fields (breaking previous "free" behavior). And just defining the list of fields in a second place (tests) seems a bit wasted/stupid as a test. I must say I don't see the point in having the variable fieldnames, unless we loop over it, but maybe there are some builtin class CustomDict(dict):
fieldnames = ['name', 'age', 'email']
def __setitem__(self, key, value):
if key not in self.fieldnames:
raise KeyError(f"Invalid key: {key}. Allowed keys are {self.fieldnames}")
super().__setitem__(key, value) import pytest
from your_module import CustomDict # Import your class
def test_valid_keys():
data = CustomDict()
data['name'] = 'Alice' # Should work
data['age'] = 30 # Should work
def test_invalid_key():
data = CustomDict()
with pytest.raises(KeyError, match="Invalid key: address"):
data['address'] = '123 Street' # Should fail |
Hello. I tend to agree that a test seems a bit of an overkill. On the other hand I'm sad the bug did not get caught. |
Yeah, I agree with you both that adding a test as is seems like a lot of superfluous work. I think we can skip that for this PR and maybe just call this good? Though I agree with @APN-Pucky that I don't off the top of my head remember why Line 251 in 7519967
as Lines 340 to 342 in 7519967
and so Ah I guess looking a bit more the @APN-Pucky @eduardo-rodrigues If we don't explicitly use Line 251 in 7519967
then should we keep them at all? (I am going through this quickly while task switching, so I might be missing the obvious.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me approve also. Let's get this bug fix in asap and then continue with the other bigger update and improvement from you @APN-Pucky.
(I won't be responsive in the next few days.)
Fixes the bug in Issue #281
Not sure we have a good test at the moment though.