-
Notifications
You must be signed in to change notification settings - Fork 31
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
Only consider snaktype 'value' in entity.getlist (Fixes #18) #19
Conversation
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.
Thanks for your contribution! The build failed, but it was due to outdated .travis.yml settings; as I just fixed this in the master branch, please rebase this commit on the current master.
Oh, and could you write a changelog about this patch in docs/changes.rst file? This change should be in the topmost section (Version 0.7.0
).
@@ -188,7 +188,8 @@ def getlist(self, key: 'Entity') -> Sequence[object]: | |||
__import__('pprint').pformat(claims)) | |||
decode = self.client.decode_datavalue | |||
return [decode(snak['datatype'], snak['datavalue']) | |||
for snak in (claim['mainsnak'] for claim in claims)] | |||
for snak in (claim['mainsnak'] for claim in claims) | |||
if snak['snaktype'] == 'value'] |
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 add a test for this case? See also other tests in tests/entity_test.py file. You could run tests using tox.
FYI you can make a fixture by fetching Q8646
:
curl -o tests/fixtures/entities/Q8646.json \
https://www.wikidata.org/wiki/Special:EntityData/Q8646.json
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 added the test case you requested. I verified that it fails before, but succeeds after this change.
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 write a changelog about this patch in docs/changes.rst file? This change should be in the topmost section (Version 0.7.0
).
I amended the commit to include a changelog. |
Thank you! |
This implements my proposed solution for #18: no value entries are simply discarded.