Skip to content

Commit

Permalink
Avoid redefining future.utils.text_type (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored and adrienball committed Apr 23, 2019
1 parent d54db13 commit 87b1387
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions snips_nlu/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import numpy as np
import pkg_resources
from future.utils import PY3
from future.utils import text_type

from snips_nlu.constants import (
END, START, RES_MATCH_RANGE, ENTITY_KIND, RES_VALUE)
Expand Down Expand Up @@ -94,17 +94,12 @@ def json_string(json_object, indent=2, sort_keys=True):


def unicode_string(string):
if PY3:
unicode_type = str
else:
unicode_type = unicode

if isinstance(string, unicode_type):
if isinstance(string, text_type):
return string
if isinstance(string, bytes):
return string.decode("utf8")
if isinstance(string, newstr):
return unicode_type(string)
return text_type(string)
if isinstance(string, newbytes):
string = bytes(string).decode("utf8")

Expand Down

0 comments on commit 87b1387

Please sign in to comment.