8000 [luigi.six.string_types] and [luigi.six.binary_type] removed by drowoseque · Pull Request #2838 · spotify/luigi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[luigi.six.string_types] and [luigi.six.binary_type] removed #2838

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

Merged
merged 26 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions luigi/contrib/docker_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import luigi

from luigi.local_target import LocalFileSystem
from luigi import six

logger = logging.getLogger('luigi-interface')

Expand Down Expand Up @@ -158,7 +157,7 @@ def __init__(self, *args, **kwargs):
self.environment['LUIGI_TMP_DIR'] = self.container_tmp_dir

# add additional volume binds specified by the user to the tmp_Dir bind
if isinstance(self.binds, six.string_types):
if isinstance(self.binds, str):
self._binds.append(self.binds)
elif isinstance(self.binds, list):
self._binds.extend(self.binds)
Expand Down
4 changes: 1 addition & 3 deletions luigi/contrib/esindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def docs(self):

import luigi

from luigi import six

logger = logging.getLogger('luigi-interface')

try:
Expand Down Expand Up @@ -366,7 +364,7 @@ def _docs(self):
iterdocs = iter(self.docs())
first = next(iterdocs)
needs_parsing = False
if isinstance(first, six.string_types):
if isinstance(first, str):
needs_parsing = True
elif isinstance(first, dict):
pass
Expand Down
4 changes: 2 additions & 2 deletions luigi/contrib/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ def put_multiple(self, filepaths, remote_directory, mimetype=None, chunksize=Non

def put_string(self, contents, dest_path, mimetype=None):
mimetype = mimetype or mimetypes.guess_type(dest_path)[0] or DEFAULT_MIMETYPE
assert isinstance(mimetype, six.string_types)
if not isinstance(contents, six.binary_type):
assert isinstance(mimetype, str)
if not isinstance(contents, bytes):
contents = contents.encode("utf-8")
media = http.MediaIoBaseUpload(six.BytesIO(contents), mimetype, resumable=bool(contents))
self._do_put(media, dest_path)
Expand Down
2 changes: 1 addition & 1 deletion luigi/contrib/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def output(self):
)

def copy(self, cursor, file):
if isinstance(self.columns[0], six.string_types):
if isinstance(self.columns[0], str):
column_names = self.columns
elif len(self.columns[0]) == 2:
column_names = [c[0] for c in self.columns]
Expand Down
5 changes: 2 additions & 3 deletions luigi/contrib/spark.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import pickle

from luigi import six
from luigi.contrib.external_program import ExternalProgramTask
from luigi import configuration

Expand Down Expand Up @@ -234,11 +233,11 @@ def app_command(self):
return [self.app] + self.app_options()

def _list_config(self, config):
if config and isinstance(config, six.string_types):
if config and isinstance(config, str):
return list(map(lambda x: x.strip(), config.split(',')))

def _dict_config(self, config):
if config and isinstance(config, six.string_types):
if config and isinstance(config, str):
return dict(map(lambda i: i.split('=', 1), config.split('|')))

def _text_arg(self, name, value):
Expand Down
3 changes: 1 addition & 2 deletions luigi/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import sys

from luigi import six
from luigi import target
from luigi.format import get_default_format

Expand Down Expand Up @@ -139,7 +138,7 @@ def write(self, data):
if mock_target._mirror_on_stderr:
if self._write_line:
sys.stderr.write(fn + ": ")
if six.binary_type:
if bytes:
sys.stderr.write(data.decode('utf8'))
else:
sys.stderr.write(data)
Expand Down
6 changes: 3 additions & 3 deletions luigi/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def serialize(self, x):
def _warn_on_wrong_param_type(self, param_name, param_value):
if self.__class__ != Parameter:
return
if not isinstance(param_value, six.string_types):
if not isinstance(param_value, str):
warnings.warn('Parameter "{}" with value "{}" is not of type string.'.format(param_name, param_value))

def normalize(self, x):
Expand Down Expand Up @@ -339,7 +339,7 @@ def parse(self, x):
def _warn_on_wrong_param_type(self, param_name, param_value):
if self.__class__ != OptionalParameter:
return
if not isinstance(param_value, six.string_types) and param_value is not None:
if not isinstance(param_value, str) and param_value is not None:
warnings.warn('OptionalParameter "{}" with value "{}" is not of type string or None.'.format(
param_name, param_value))

Expand Down Expand Up @@ -949,7 +949,7 @@ def parse(self, source):
:param s: String to be parse
"""
# TOML based config convert params to python types itself.
if not isinstance(source, six.string_types):
if not isinstance(source, str):
return source
return json.loads(source, object_pairs_hook=FrozenOrderedDict)

Expand Down
4 changes: 0 additions & 4 deletions luigi/six.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,15 @@
PY34 = sys.version_info[0:2] >= (3, 4)

if PY3:
string_types = str,
integer_types = int,
class_types = type,
text_type = str
binary_type = bytes

MAXSIZE = sys.maxsize
else:
string_types = basestring,
integer_types = (int, long)
class_types = (type, types.ClassType)
text_type = unicode
binary_type = str

if sys.platform.startswith("java"):
# Jython always uses 32 bits.
Expand Down
4 changes: 2 additions & 2 deletions luigi/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _owner_list(self):
owner_email = self.owner_email
if owner_email is None:
return []
elif isinstance(owner_email, six.string_types):
elif isinstance(owner_email, str):
return owner_email.split(',')
else:
return owner_email
Expand Down Expand Up @@ -870,7 +870,7 @@ def flatten(struct):
for _, result in six.iteritems(struct):
flat += flatten(result)
return flat
if isinstance(struct, six.string_types):
if isinstance(struct, str):
return [struct]

try:
Expand Down
2 changes: 1 addition & 1 deletion luigi/tools/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def of_cls(self):
"""
DONT USE. Will be deleted soon. Use ``self.of``!
"""
if isinstance(self.of, six.string_types):
if isinstance(self.of, str):
warnings.warn('When using Range programatically, dont pass "of" param as string!')
return Register.get_task_cls(self.of)
return self.of
Expand Down
3 changes: 1 addition & 2 deletions test/contrib/hdfs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import luigi
import luigi.format
from luigi.contrib import hdfs
from luigi import six
import luigi.contrib.hdfs.clients

from target_test import FileSystemTargetTestMixin
Expand Down Expand Up @@ -171,7 +170,7 @@ def test_glob_exists(self):

def assertRegexpMatches(self, text, expected_regexp, msg=None):
"""Python 2.7 backport."""
if isinstance(expected_regexp, six.string_types):
if isinstance(expected_regexp, str):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(text):
msg = msg or "Regexp didn't match"
Expand Down
0