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

Make object_provides work also on tuple #267

Merged
merged 2 commits into from
Jul 30, 2015
Merged

Conversation

ale-rt
Copy link
Member

@ale-rt ale-rt commented Jul 30, 2015

Fixes #266

@@ -549,12 +549,11 @@ def find(context=None, depth=None, **kwargs):
# Convert interfaces to their identifiers
object_provides = query.get('object_provides', [])
if object_provides:
if not isinstance(object_provides, list):
if not isinstance(object_provides, (list, tuple)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make the function work with all iterable types? This would work:

import collections
if isinstance(object_provides, collections.Iterable):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are right, this is not the best possible solution.

Anyway checking for collections.Iterable leads you to problem in case of dicts and strings:

>>> a = {}
>>> b =''
>>> import collections
>>> isinstance(a, collections.Iterable)
True
>>> isinstance(b, collections.Iterable)
True

This would lead to additional "if"s :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah true. Fair point.

@jensens
Copy link
Sponsor Member

jensens commented Jul 30, 2015

please add a note to the changelog

@ale-rt
Copy link
Member Author

ale-rt commented Jul 30, 2015

@jensens done ;)

adamcheasley pushed a commit that referenced this pull request Jul 30, 2015
Make object_provides work also on tuple
@adamcheasley adamcheasley merged commit e8cda67 into master Jul 30, 2015
@adamcheasley adamcheasley deleted the 266-fix-object-provides branch July 30, 2015 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants