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

Always replace unicode() with six.text_type #38

Merged
merged 4 commits into from
Sep 5, 2014

Conversation

brettcannon
Copy link
Contributor

No description provided.

@brettcannon
Copy link
Contributor Author

Fixed the libmodernize.fixes.init problem and created #39 for discussion.

@takluyver
Copy link
Contributor

This looks good, but I wonder if we should get rid of the check that it's called. The other main use for the name unicode is in isinstance checks, where replacing it with text_type does make sense. Or there could be a separate fix that checks for isinstance(x, unicode).

@brettcannon
Copy link
Contributor Author

Patch updated to substitute all found instances of unicode with six.text_type.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 0c9efdc on brettcannon:unicode_callable into * on python-modernize:master*.


def transform(self, node, results):
touch_import(None, u'six', node)
return Name(u'six.text_type', prefix=node.prefix)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would lean towards doing from six import text_type and then using the name text_type, because then it's easier to change if you're using your own compatibility code instead of six.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would go against the current practice in the other fixers of only doing from six import ... statements when doing global overrides, e.g. for map. Plus not using 'six' is such a pain even I gave up trying after all those issues I filed about it.

But if your leanings are more requirements I'll change the code (I obviously have a personal aversion to importing things directly from modules which is why I'm pushing back a little =).

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fair enough. It's only a leaning, not a requirement, and I accept your leanings in the other direction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for understanding. =)

takluyver added a commit that referenced this pull request Sep 5, 2014
Always replace `unicode()` with `six.text_type`
@takluyver takluyver merged commit baf1624 into PyCQA:master Sep 5, 2014
@brettcannon brettcannon deleted the unicode_callable branch September 5, 2014 19:55
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.

4 participants