Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Tighten up PyLint directives again #12322

Merged
merged 3 commits into from
Aug 24, 2018
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
20 changes: 7 additions & 13 deletions ci/other/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,15 @@ enable=indexing-exception,old-raise-syntax,undefined-variable
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=
design,
similarities,
no-self-use,
attribute-defined-outside-init,
locally-disabled,
star-args,
pointless-except,
bad-option-value,
global-statement,
fixme,
suppressed-message,
useless-suppression,
locally-enabled,
no-member,
no-name-in-module,
import-error,
unsubscriptable-object,
unbalanced-tuple-unpacking,
protected-access,
superfluous-parens,
invalid-name,
Expand All @@ -111,15 +102,18 @@ disable=
chained-comparison,
consider-using-dict-comprehension,
consider-using-set-comprehension,
invalid-envvar-default,
singleton-comparison,
try-except-raise,
useless-object-inheritance,
useless-return,
c-extension-no-member,
deprecated-lambda,
redefined-builtin,
unexpected-keyword-arg
too-few-public-methods,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
too-many-locals,
too-many-public-methods,
too-many-statements

# disable=unicode-builtin,delslice-method,using-cmp-argument,setslice-method,dict-view-method,parameter-unpacking,range-builtin-not-iterating,print-statement,file-builtin,old-raise-syntax,basestring-builtin,execfile-builtin,indexing-exception,import-star-module-level,coerce-method,long-builtin,old-ne-operator,old-division,no-absolute-import,raw_input-builtin,old-octal-literal,oct-method,xrange-builtin,hex-method,unpacking-in-except,nonzero-method,raising-string,intern-builtin,reload-builtin,metaclass-assignment,cmp-method,filter-builtin-not-iterating,apply-builtin,map-builtin-not-iterating,next-method-called,unichr-builtin,buffer-builtin,dict-iter-method,input-builtin,coerce-builtin,getslice-method,useless-suppression,standarderror-builtin,zip-builtin-not-iterating,suppressed-message,cmp-builtin,backtick,long-suffix,reduce-builtin,round-builtin

Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def _get_op_name_prefix(op_name):
return ""


# pylint: enable=too-many-locals, invalid-name
# pylint: enable=invalid-name
def _init_op_module(root_namespace, module_name, make_op_func):
"""
Registers op functions created by `make_op_func` under
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/executor_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _bind_exec(sym, ctx, input_shapes, param_names, need_grad=False,
assert(arg_types is not None)

arg_arrays = []
grad_arrays = {} if need_grad != False else None
grad_arrays = {} if need_grad is not False else None

arg_names = sym.list_arguments()

Expand Down
14 changes: 6 additions & 8 deletions python/mxnet/gluon/rnn/rnn_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,12 @@ def unroll(self, length, inputs, begin_state=None, layout='NTC', merge_outputs=N
#pylint: disable=no-self-use
def _get_activation(self, F, inputs, activation, **kwargs):
"""Get activation function. Convert if is string"""
if activation == 'tanh':
return F.tanh(inputs, **kwargs)
elif activation == 'sigmoid':
return F.sigmoid(inputs, **kwargs)
elif activation == 'relu':
return F.relu(inputs, **kwargs)
elif activation == 'softsign':
return F.softsign(inputs, **kwargs)
func = {'tanh': F.tanh,
'relu': F.relu,
'sigmoid': F.sigmoid,
'softsign': F.softsign}.get(activation)
if func:
return func(inputs, **kwargs)
elif isinstance(activation, string_types):
return F.Activation(inputs, act_type=activation, **kwargs)
elif isinstance(activation, LeakyReLU):
Expand Down
3 changes: 1 addition & 2 deletions python/mxnet/image/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ def _random_crop_proposal(self, label, height, width):
h -= 1
w = int(round(h * ratio))
area = w * h
if (area < min_area or area > max_area or w > width or h > height \
or w <= 0 or h <= 0):
if not (min_area <= area <= max_area and 0 <= w <= width and 0 <= h <= height):
continue

y = random.randint(0, max(0, height - h))
Expand Down
3 changes: 1 addition & 2 deletions python/mxnet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def _update_params_on_kvstore_nccl(param_arrays, grad_arrays, kvstore, param_nam
size = len(valid_grad_arrays)
start = 0
# Use aggregation by default only with NCCL
default_batch = 16
default_batch = '16'
batch = int(os.getenv('MXNET_UPDATE_AGGREGATION_SIZE', default_batch))
while start < size:
end = start + batch if start + batch < size else size
Expand Down Expand Up @@ -378,7 +378,6 @@ def _train_multi_device(symbol, ctx, arg_names, param_names, aux_names,
_multiple_callbacks(eval_end_callback, eval_end_params)
eval_data.reset()
# end of all epochs
return


def save_checkpoint(prefix, epoch, symbol, arg_params, aux_params):
Expand Down
1 change: 1 addition & 0 deletions python/mxnet/ndarray/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ..base import mx_uint, check_call, _LIB, py_str, _init_op_module, _Null # pylint: disable=unused-import


# pylint: disable=too-many-locals
def _generate_ndarray_function_code(handle, name, func_name, signature_only=False):
"""Generate function for ndarray op by handle and function name."""
real_name = ctypes.c_char_p()
Expand Down
1 change: 1 addition & 0 deletions python/mxnet/symbol/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ def _get_ndarray_inputs(arg_key, args, arg_names, allow_missing):
raise TypeError('Only accept list of NDArrays or dict of str to NDArray')
return c_array(NDArrayHandle, arg_handles), arg_arrays

# pylint: disable=too-many-locals
def simple_bind(self, ctx, grad_req='write', type_dict=None, stype_dict=None,
group2ctx=None, shared_arg_names=None, shared_exec=None,
shared_buffer=None, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def makedirs(d):
from distutils.dir_util import mkpath
mkpath(d)
else:
os.makedirs(d, exist_ok=True)
os.makedirs(d, exist_ok=True) # pylint: disable=unexpected-keyword-arg
3 changes: 2 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from __future__ import absolute_import
import os
import sys

from setuptools import find_packages
# need to use distutils.core for correct placement of cython dll
kwargs = {}
if "--inplace" in sys.argv:
Expand All @@ -29,7 +31,6 @@
from setuptools import setup
from setuptools.extension import Extension
kwargs = {'install_requires': ['numpy<=1.15.0,>=1.8.2', 'requests<2.19.0,>=2.18.4', 'graphviz<0.9.0,>=0.8.1'], 'zip_safe': False}
from setuptools import find_packages

with_cython = False
if '--with-cython' in sys.argv:
Expand Down