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

Refs #14030 -- Improved expression support for python values #4107

Merged
merged 1 commit into from
Feb 11, 2015

Conversation

jarshwah
Copy link
Member

Parsing non-expressions now only wraps strings in F() and everything else as Value(). Thanks @charettes for the idea.

@charettes
Copy link
Member

LGTM, It removes a lot of boilerplate!

@coldmind
Copy link
Contributor

Refs #4105

def _parse_expressions(self, *expressions):
return [
arg if hasattr(arg, 'resolve_expression') else (
F(arg) if isinstance(arg, six.string_types) else Value(arg)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should include six.text_type to isinstance check too.

Copy link
Member

Choose a reason for hiding this comment

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

No need for that. text_type is a subset of string_types.

Python 3:

>>> six.text_type
<class 'str'>
>>> six.string_types
(<class 'str'>,)

Python 2:

>>> six.text_type
<type 'unicode'>
>>> six.string_types
(<type 'basestring'>,)
>>> str.__bases__
(<type 'basestring'>,)
>>> unicode.__bases__
(<type 'basestring'>,)

@timgraham
Copy link
Member

Fine with me for 1.8.

@jarshwah jarshwah merged commit e2d6e14 into django:master Feb 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants