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

Revert py3modernize lint changes #34339

Merged
merged 12 commits into from
Jun 28, 2016
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
2 changes: 1 addition & 1 deletion salt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __define_global_system_encoding_variable__():
# than expected. See:
# https://github.com/saltstack/salt/issues/21036
if sys.version_info[0] < 3:
import __builtin__ as builtins
import __builtin__ as builtins # pylint: disable=incompatible-py3-code
else:
import builtins # pylint: disable=import-error

Expand Down
2 changes: 1 addition & 1 deletion salt/cloud/clouds/vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

# Disable InsecureRequestWarning generated on python > 2.6
try:
from requests.packages.urllib3 import disable_warnings
from requests.packages.urllib3 import disable_warnings # pylint: disable=no-name-in-module
disable_warnings()
except Exception:
pass
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/jboss7_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def __is_long(token):

def __get_long(token):
if six.PY2:
return long(token[0:-1])
return long(token[0:-1]) # pylint: disable=incompatible-py3-code
else:
return int(token[0:-1])

Expand Down
4 changes: 3 additions & 1 deletion salt/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ def verylong_encoder(obj):
for idx, entry in enumerate(obj):
obj[idx] = verylong_encoder(entry)
return obj
if six.PY2 and isinstance(obj, long) and long > pow(2, 64):
# This is a spurious lint failure as we are gating this check
# behind a check for six.PY2.
if six.PY2 and isinstance(obj, long) and long > pow(2, 64): # pylint: disable=incompatible-py3-code
return str(obj)
elif six.PY3 and isinstance(obj, int) and int > pow(2, 64):
return str(obj)
Expand Down
2 changes: 1 addition & 1 deletion salt/serializers/yamlex.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def represent_odict(self, data):
if six.PY2:
Dumper.add_multi_representer(six.binary_type, Dumper.represent_str)
Dumper.add_multi_representer(six.text_type, Dumper.represent_unicode)
Dumper.add_multi_representer(long, Dumper.represent_long)
Dumper.add_multi_representer(long, Dumper.represent_long) # pylint: disable=incompatible-py3-code
else:
Dumper.add_multi_representer(six.binary_type, Dumper.represent_binary)
Dumper.add_multi_representer(six.text_type, Dumper.represent_str)
Expand Down
1 change: 1 addition & 0 deletions salt/states/win_servermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'''
Manage Windows features via the ServerManager powershell module
'''
from __future__ import absolute_import

# Import salt modules
import salt.utils
Expand Down
10 changes: 3 additions & 7 deletions salt/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2038,11 +2038,7 @@ def alias_function(fun, name, doc=None):
if doc and isinstance(doc, six.string_types):
alias_fun.__doc__ = doc
else:
if six.PY3:
orig_name = fun.__name__
else:
orig_name = fun.func_name

orig_name = fun.__name__
alias_msg = ('\nThis function is an alias of '
'``{0}``.\n'.format(orig_name))
alias_fun.__doc__ = alias_msg + fun.__doc__
Expand Down Expand Up @@ -2820,7 +2816,7 @@ def to_str(s, encoding=None):
else:
if isinstance(s, bytearray):
return str(s)
if isinstance(s, unicode):
if isinstance(s, unicode): # pylint: disable=incompatible-py3-code
return s.encode(encoding or __salt_system_encoding__)
raise TypeError('expected str, bytearray, or unicode')

Expand Down Expand Up @@ -2851,7 +2847,7 @@ def to_unicode(s, encoding=None):
else:
if isinstance(s, str):
return s.decode(encoding or __salt_system_encoding__)
return unicode(s)
return unicode(s) # pylint: disable=incompatible-py3-code


def is_list(value):
Expand Down
2 changes: 1 addition & 1 deletion salt/utils/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def condition_input(args, kwargs):
# XXX: We might need to revisit this code when we move to Py3
# since long's are int's in Py3
if (six.PY3 and isinstance(arg, six.integer_types)) or \
(six.PY2 and isinstance(arg, long)):
(six.PY2 and isinstance(arg, long)): # pylint: disable=incompatible-py3-code
ret.append(str(arg))
else:
ret.append(arg)
Expand Down
2 changes: 1 addition & 1 deletion salt/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def deepcopy_bound(name):

'''
def _deepcopy_method(x, memo):
return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class)
return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class) # pylint: disable=incompatible-py3-code
try:
pre_dispatch = copy._deepcopy_dispatch
copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method
Expand Down
18 changes: 9 additions & 9 deletions salt/utils/decorators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,13 @@ def _call_function(self, kwargs):
try:
return self._function(*args, **kwargs)
except TypeError as error:
error = str(error).replace(self._function.func_name, self._orig_f_name) # Hide hidden functions
error = str(error).replace(self._function.__name__, self._orig_f_name) # Hide hidden functions
log.error('Function "{f_name}" was not properly called: {error}'.format(f_name=self._orig_f_name,
error=error))
return self._function.__doc__
except Exception as error:
log.error('Unhandled exception occurred in '
'function "{f_name}: {error}'.format(f_name=self._function.func_name,
'function "{f_name}: {error}'.format(f_name=self._function.__name__,
error=error))
raise error
else:
Expand All @@ -324,7 +324,7 @@ def __call__(self, function):
:return:
'''
self._function = function
self._orig_f_name = self._function.func_name
self._orig_f_name = self._function.__name__


class _IsDeprecated(_DeprecationDecorator):
Expand Down Expand Up @@ -405,13 +405,13 @@ def _decorate(*args, **kwargs):
'''
if self._curr_version < self._exp_version:
msg = ['The function "{f_name}" is deprecated and will '
'expire in version "{version_name}".'.format(f_name=self._function.func_name,
'expire in version "{version_name}".'.format(f_name=self._function.__name__,
version_name=self._exp_version_name)]
if self._successor:
msg.append('Use successor "{successor}" instead.'.format(successor=self._successor))
log.warning(' '.join(msg))
else:
msg = ['The lifetime of the function "{f_name}" expired.'.format(f_name=self._function.func_name)]
msg = ['The lifetime of the function "{f_name}" expired.'.format(f_name=self._function.__name__)]
if self._successor:
msg.append('Please use its successor "{successor}" instead.'.format(successor=self._successor))
log.warning(' '.join(msg))
Expand Down Expand Up @@ -513,13 +513,13 @@ def _set_function(self, function):
:return:
'''
full_name = "{m_name}.{f_name}".format(m_name=self._globals.get(self.MODULE_NAME, ''),
f_name=function.func_name)
f_name=function.__name__)
if full_name.startswith("."):
self._raise_later = CommandExecutionError('Module not found for function "{f_name}"'.format(
f_name=function.func_name))
f_name=function.__name__))

if full_name in self._options.get(self.CFG_KEY, list()):
self._function = self._globals.get(self._with_name or "_{0}".format(function.func_name))
self._function = self._globals.get(self._with_name or "_{0}".format(function.__name__))

def _is_used_deprecated(self):
'''
Expand Down Expand Up @@ -565,7 +565,7 @@ def _decorate(*args, **kwargs):
log.warning(' '.join(msg))
else:
msg_patt = 'The lifetime of the function "{f_name}" expired.'
if '_' + self._orig_f_name == self._function.func_name:
if '_' + self._orig_f_name == self._function.__name__:
msg = [msg_patt.format(f_name=self._orig_f_name),
'Please turn off its deprecated version in the configuration']
else:
Expand Down
9 changes: 6 additions & 3 deletions salt/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
import sys
import platform

# Don't rely on external packages in this module since it's used at install time
# pylint: disable=invalid-name,redefined-builtin
# Import 3rd-party libs
from salt.ext import six
from salt.ext.six.moves import map

# Don't rely on external packages in this module since it's used at install time
if sys.version_info[0] == 3:
MAX_SIZE = sys.maxsize
string_types = (str,)
else:
MAX_SIZE = sys.maxint
string_types = (basestring,)
from itertools import imap as map
string_types = (six.string_types,)
# pylint: enable=invalid-name,redefined-builtin

# ----- ATTENTION --------------------------------------------------------------------------------------------------->
Expand Down
2 changes: 1 addition & 1 deletion tests/salt-tcpdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def run(self):
'tcp': {}
}

(header, packet) = cap.next()
(header, packet) = cap.next() # pylint: disable=incompatible-py3-code

eth_length, eth_protocol = self.parse_ether(packet)

Expand Down