keras-team / keras-preprocessing

Utilities for working with image data, text data, and sequence data.
Other
1.02k stars 444 forks source link

replace unicode typecasting with six.u to pass flake8 tests #264

Closed duhaime closed 4 years ago

duhaime commented 4 years ago

Summary

This PR replaces the unicode() type reference and typecasting call (both of which are only available in Python 2) in the text module with six.u() which is available in Python 2 and 3.

This change prevents flake8 from barking about undefined references when running flake tests in Python 3.

Related Issues

N/A

PR Overview

rragundez commented 4 years ago

I don't know what you mean with to pass flake8 tests. The current master does pass PEP8 tests.

rragundez commented 4 years ago

In this case the lines you are changing only get t executed for Python 2 and not for Python 3, I am OK ignoring the flake8 violation of those 2 lines. Something like:

        if isinstance(text, unicode):  # noqa: F821
            translate_map = dict(
                (ord(c), unicode(split)) for c in filters  # noqa: F821
            )

But it is a good point to take in general. Create a PEP8 with Python 3.

rragundez commented 4 years ago

I hope you don't mind but I made the changes in https://github.com/keras-team/keras-preprocessing/pull/265 I had to make them because I also introduced the Python3 PEP8 Travis stage check, which made the CI fail.

duhaime commented 4 years ago

no worries!