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

Only consider snaktype 'value' in entity.getlist (Fixes #18) #19

Merged
merged 2 commits into from
Aug 20, 2019

Conversation

Yorwba
Copy link
Contributor

@Yorwba Yorwba commented Aug 19, 2019

This implements my proposed solution for #18: no value entries are simply discarded.

Copy link
Owner

@dahlia dahlia left a 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']
Copy link
Owner

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

Copy link
Contributor Author

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.

@dahlia dahlia assigned dahlia and unassigned dahlia Aug 20, 2019
@dahlia dahlia added the bug label Aug 20, 2019
Copy link
Owner

@dahlia dahlia left a 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).

@Yorwba
Copy link
Contributor Author

Yorwba commented Aug 20, 2019

I amended the commit to include a changelog.

@dahlia dahlia merged commit 3240c01 into dahlia:master Aug 20, 2019
@dahlia
Copy link
Owner

dahlia commented Aug 20, 2019

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants