-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
List wildcard #114
List wildcard #114
Conversation
type_util.py - add wildcard index, add only dicts check __init__.py - clean naive test run keylist_dict.py - add condition for wildcard key keylist_util.py - enhance condition for wildcard
Codecov ReportBase: 96.96% // Head: 96.59% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #114 +/- ##
==========================================
- Coverage 96.96% 96.59% -0.37%
==========================================
Files 57 57
Lines 1678 1793 +115
==========================================
+ Hits 1627 1732 +105
- Misses 51 61 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Thank you very much the good PR and the effort.
This PR brings wildcard *
support to lists when using keypaths
, with this feature all methods that accept a key should works as correctly and as expected when a *
is present, but there are not tests at all for all other methods except for the rename
method.
As this is an important feature that involves the whole library it needs to be tested well against all methods, a couple of new test cases are mandatory:
tests.dicts.test_keypath_dict_list_wildcard
(core operations)tests.dicts.test_benedict_wildcard
(methods implementation)
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.
Could you provide also the test cases?
Yes, will do that in the evening.
…On Tue, Sep 13, 2022, 16:37 Fabio Caccamo ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Could you provide also the test cases?
—
Reply to this email directly, view it on GitHub
<#114 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEKTQBU6VMNI5S3JGPA34BTV6CGTXANCNFSM6AAAAAAQK3W7F4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
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.
We should be ok with the changes, just need the tests.
I'm pretty sure that adding the tests against all methods there will be something to adjust.
I am going through methods of benedict class. I am trying to figure out all the methods for tests. |
Feel free to check it and let me know what you want to do with it. Cause
there is TypeError if I remember it correctly.
…On Wed, Sep 14, 2022, 15:40 Fabio Caccamo ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In tests/dicts/test_benedict_wildcard.py
<#114 (comment)>
:
> + self.assertEqual(b, result)
+
+ def test_swap_wildcard(self):
+ self.d = {
+ "a": [
+ {"x": 1, "y": 1},
+ {"x": 2, "y": 2},
+ ],
+ "x": [
+ {"a": 10, "b": 10},
+ {"a": 11, "b": 11},
+ ],
+ }
+ b = benedict(d)
+ b = benedict(b.clone())
+ b.swap("a[*].x", "x[*].a")
I'm curious to see what happens using keypaths that end with [*] without
a final dict key.
—
Reply to this email directly, view it on GitHub
<#114 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEKTQBXQ3I6GVTDRT4BBGFDV6HITHANCNFSM6AAAAAAQK3W7F4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
if you want to cover this more thoroughly by test, can you help me and compile the list of methods you want to cover? |
@milhauzindahauz I would absolutely cover all methods with at least a couple of different cases (eg. wildcard alone / at the beginning / in the middle / at the end of keypaths), this library is widely used, I don't want to see tens of issues open after this feature will be released. |
for more information, see https://pre-commit.ci
Apologies for the pre-commit errors but there is configured max-line-length for flake8 in setup.cfg. But it seems to me that black is using the default value in the CI. Am I wrong? |
Thank you for noticing it, probably there is a conflict between |
black doesn't support |
for more information, see https://pre-commit.ci
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.
I don't have anything else to this feature.
elif __item: | ||
yield __item | ||
elif type_util.is_dict(_item) and index in _item: | ||
yield _item[index] |
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.
If _item
is tuple
, it will not enter any of the conditions above.
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.
I don't understand the purpose of this method, could you explain it please?
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.
this method is allowing to travers through complex list and return references to objects on the lowest level of them.
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.
The PR doesn't pass tests.
I will need to make changes, again. |
implements #113