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

Upgrade Pylint version to 2.3.1 #14807

Merged
merged 8 commits into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from 7 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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ cpplint:
--exclude_path src/operator/contrib/ctc_include

pylint:
pylint --rcfile=$(ROOTDIR)/ci/other/pylintrc --ignore-patterns=".*\.so$$,.*\.dll$$,.*\.dylib$$" python/mxnet tools/caffe_converter/*.py
python3 -m pylint --rcfile=$(ROOTDIR)/ci/other/pylintrc --ignore-patterns=".*\.so$$,.*\.dll$$,.*\.dylib$$" python/mxnet tools/caffe_converter/*.py

doc: docs

Expand Down
4 changes: 2 additions & 2 deletions ci/docker/install/ubuntu_publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ python2 get-pip.py

apt-get remove -y python3-urllib3

pip2 install nose cpplint==1.3.0 pylint==1.9.3 'numpy<=1.15.2,>=1.8.2' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3
pip3 install nose cpplint==1.3.0 pylint==2.1.1 'numpy<=1.15.2,>=1.8.2' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3
pip2 install nose cpplint==1.3.0 'numpy<=1.15.2,>=1.8.2' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3
pip3 install nose cpplint==1.3.0 pylint==2.3.1 'numpy<=1.15.2,>=1.8.2' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3
4 changes: 2 additions & 2 deletions ci/docker/install/ubuntu_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ wget -nv https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
python2 get-pip.py

pip2 install nose cpplint==1.3.0 pylint==1.9.3 'numpy<=1.15.2,>=1.8.2' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3
pip3 install nose cpplint==1.3.0 pylint==2.1.1 'numpy<=1.15.2,>=1.8.2' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3
pip2 install nose cpplint==1.3.0 'numpy<=1.15.2,>=1.8.2' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3
pip3 install nose cpplint==1.3.0 pylint==2.3.1 'numpy<=1.15.2,>=1.8.2' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3
2 changes: 1 addition & 1 deletion cpp-package/tests/travis/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@


if [ ${TASK} == "lint" ]; then
pip install cpplint 'pylint==1.4.4' 'astroid==1.3.6' --user
pip3 install cpplint 'pylint==2.3.1' --user
fi
2 changes: 1 addition & 1 deletion docs/install/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ h5py==2.8.0rc1
nose
nose-timer
numpy<=1.15.2,>=1.8.2
pylint==1.8.3
pylint==2.3.1; python_version >= '3.0'
requests<2.19.0,>=2.18.4
scipy==1.0.1
2 changes: 1 addition & 1 deletion python/mxnet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# coding: utf-8
# pylint: disable=invalid-name, no-member, trailing-comma-tuple, bad-mcs-classmethod-argument
# pylint: disable=invalid-name, no-member, trailing-comma-tuple, bad-mcs-classmethod-argument, unnecessary-pass
"""ctypes library of mxnet and helper functions."""
from __future__ import absolute_import

Expand Down
1 change: 1 addition & 0 deletions python/mxnet/contrib/onnx/mx2onnx/_export_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.
"""export helper functions"""
# coding: utf-8
# pylint: disable=no-else-raise
import os
import logging
import mxnet as mx
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/contrib/onnx/mx2onnx/_op_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def convert_leakyrelu(node, **kwargs):
act_name = {"elu": "Elu", "leaky": "LeakyRelu", "prelu": "PRelu",
"selu": "Selu"}

if act_type == "prelu" or act_type == "selu":
if act_type in ("prelu", "selu"):
node = onnx.helper.make_node(
act_name[act_type],
inputs=input_nodes,
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# coding: utf-8
"""Utilities used for translating operators from Onnx to Mxnet."""
# pylint: disable=protected-access
# pylint: disable=protected-access, no-else-raise
from __future__ import absolute_import as _abs
from .... import symbol
from .... import module
Expand Down
2 changes: 2 additions & 0 deletions python/mxnet/contrib/quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# pylint: disable=unbalanced-tuple-unpacking
"""Quantization module for generating quantized (INT8) models from FP32 models."""

from __future__ import absolute_import
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/contrib/text/vocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# coding: utf-8
# pylint: disable=consider-iterating-dictionary
# pylint: disable=consider-iterating-dictionary, no-else-raise

"""Text token indexer."""
from __future__ import absolute_import
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/gluon/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# coding: utf-8
# pylint: disable=
# pylint: disable=unnecessary-pass
"""Neural network parameter."""
__all__ = ['DeferredInitializationError', 'Parameter', 'Constant',
'ParameterDict', 'tensor_types']
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/gluon/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# coding: utf-8
# pylint: disable=line-too-long
# pylint: disable=line-too-long, no-else-raise
eric-haibin-lin marked this conversation as resolved.
Show resolved Hide resolved
"""Parameter optimizer."""
__all__ = ['Trainer']

Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/gluon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# coding: utf-8
# pylint: disable=
# pylint: disable=no-else-raise
"""Parallelization utility optimizer."""
__all__ = ['split_data', 'split_and_load', 'clip_global_norm',
'check_sha1', 'download']
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/image/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

# pylint: disable=unused-import
# pylint: disable=unused-import, no-else-raise
"""Read images and perform augmentations for object detection."""

from __future__ import absolute_import, print_function
Expand Down
1 change: 1 addition & 0 deletions python/mxnet/image/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# pylint: disable=no-member, too-many-lines, redefined-builtin, protected-access, unused-import, invalid-name
# pylint: disable=too-many-arguments, too-many-locals, no-name-in-module, too-many-branches, too-many-statements
# pylint: disable=no-else-raise
"""Read individual image files and perform augmentations."""

from __future__ import absolute_import, print_function
Expand Down
2 changes: 2 additions & 0 deletions python/mxnet/io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# specific language governing permissions and limitations
# under the License.

# coding: utf-8
# pylint: disable=unnecessary-pass
"""Data iterators for common data formats."""
from __future__ import absolute_import
from collections import namedtuple
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# pylint: disable=fixme, invalid-name, too-many-arguments, too-many-locals, too-many-lines
# pylint: disable=too-many-branches, too-many-statements
# pylint: disable=too-many-branches, too-many-statements, no-else-raise
"""MXNet model module"""
from __future__ import absolute_import, print_function

Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/module/base_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

# pylint: disable=fixme, too-many-arguments, too-many-locals
# pylint: disable=fixme, too-many-arguments, too-many-locals, no-else-raise
# pylint: disable=too-many-public-methods, too-many-branches, too-many-lines
"""`BaseModule` defines an API for modules."""

Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/module/python_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

# pylint: disable=too-many-instance-attributes, too-many-arguments
# pylint: disable=too-many-instance-attributes, too-many-arguments, unnecessary-pass
"""Provide some handy classes for user to implement a simple computation module
in Python easily.
"""
Expand Down
4 changes: 2 additions & 2 deletions python/mxnet/ndarray/contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def isfinite(data):
[0. 0. 0. 1.]
<NDArray 4 @cpu(0)>
"""
is_data_not_nan = data == data
is_data_not_nan = data == data # pylint: disable=comparison-with-itself
is_data_not_infinite = data.abs() != np.inf
return ndarray.logical_and(is_data_not_infinite, is_data_not_nan)

Expand Down Expand Up @@ -542,7 +542,7 @@ def isnan(data):
[1. 0.]
<NDArray 2 @cpu(0)>
"""
return data != data
return data != data # pylint: disable=comparison-with-itself

def adamw_update(weight, grad, mean, var, rescale_grad, lr, eta, beta1=0.9, beta2=0.999,
epsilon=1e-8, wd=0, clip_gradient=-1, out=None, name=None, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/ndarray/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# coding: utf-8
# pylint: disable=wildcard-import, unused-wildcard-import, too-many-lines
# pylint: disable=wildcard-import, unused-wildcard-import, too-many-lines, no-else-raise
"""Sparse NDArray API of MXNet."""

from __future__ import absolute_import
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/ndarray_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# coding: utf-8
# pylint: disable=unused-argument, too-many-arguments
# pylint: disable=unused-argument, too-many-arguments, unnecessary-pass
"""Extra symbol documents"""
from __future__ import absolute_import as _abs
import re as _re
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# coding: utf-8
# pylint: disable=invalid-name, protected-access, too-many-arguments, no-self-use, too-many-locals, broad-except, too-many-lines
# pylint: disable=invalid-name, protected-access, too-many-arguments, no-self-use, too-many-locals, broad-except, too-many-lines, unnecessary-pass
"""numpy interface for operators."""
from __future__ import absolute_import

Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/optimizer/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# specific language governing permissions and limitations
# under the License.

# pylint: disable=too-many-lines
# pylint: disable=too-many-lines, no-else-raise
"""Weight updating functions."""
import logging
import math
Expand Down
3 changes: 3 additions & 0 deletions python/mxnet/recordio.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# specific language governing permissions and limitations
# under the License.

# pylint: disable=not-callable
# It's bug from pylint(astroid). See /~https://github.com/PyCQA/pylint/issues/1699

"""Read and write for the RecordIO data format."""
from __future__ import absolute_import
from collections import namedtuple
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/rnn/rnn_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# coding: utf-8
# pylint: disable=no-member, invalid-name, protected-access, no-self-use
# pylint: disable=too-many-branches, too-many-arguments, no-self-use
# pylint: disable=too-many-lines
# pylint: disable=too-many-lines, unbalanced-tuple-unpacking
"""Definition of various recurrent neural network cells."""
from __future__ import print_function

Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/symbol/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,6 @@ def _infer_type_impl(self, partial, *args, **kwargs):
return (arg_types, out_types, aux_types)
else:
return (None, None, None)
# pylint: enable=too-many-locals

def infer_shape(self, *args, **kwargs):
"""Infers the shapes of all arguments and all outputs given the known shapes of
Expand Down Expand Up @@ -1071,6 +1070,7 @@ def infer_shape(self, *args, **kwargs):
List of auxiliary state shapes.
The order is same as the order of list_auxiliary_states().
"""
# pylint: disable=too-many-locals
try:
res = self._infer_shape_impl(False, *args, **kwargs)
if res[1] is None:
Expand Down
8 changes: 4 additions & 4 deletions python/mxnet/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

"""Tools for testing."""
# pylint: disable=too-many-lines
# pylint: disable=too-many-lines, no-else-raise
from __future__ import absolute_import, print_function, division
import time
import gzip
Expand Down Expand Up @@ -1536,7 +1536,7 @@ def get_mnist_iterator(batch_size, input_shape, num_parts=1, part_index=0):
"""

get_mnist_ubyte()
flat = False if len(input_shape) == 3 else True
flat = False if len(input_shape) == 3 else True # pylint: disable=simplifiable-if-expression

train_dataiter = mx.io.MNISTIter(
image="data/train-images-idx3-ubyte",
Expand Down Expand Up @@ -1990,15 +1990,15 @@ def compare_optimizer(opt1, opt2, shape, dtype, w_stype='default', g_stype='defa
if w_stype == 'default':
w2 = mx.random.uniform(shape=shape, ctx=default_context(), dtype=dtype)
w1 = w2.copyto(default_context())
elif w_stype == 'row_sparse' or w_stype == 'csr':
elif w_stype in ('row_sparse', 'csr'):
w2 = rand_ndarray(shape, w_stype, density=1, dtype=dtype)
w1 = w2.copyto(default_context()).tostype('default')
else:
raise Exception("type not supported yet")
if g_stype == 'default':
g2 = mx.random.uniform(shape=shape, ctx=default_context(), dtype=dtype)
g1 = g2.copyto(default_context())
elif g_stype == 'row_sparse' or g_stype == 'csr':
elif g_stype in ('row_sparse', 'csr'):
g2 = rand_ndarray(shape, g_stype, dtype=dtype)
g1 = g2.copyto(default_context()).tostype('default')
else:
Expand Down
5 changes: 0 additions & 5 deletions tools/caffe_converter/compare_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ def convert_and_compare_caffe_to_mxnet(image_url, gpu, caffe_prototxt_path, caff
compare_layers_from_nets(caffe_net, arg_params, aux_params, exe, layer_name_to_record,
top_to_layers, mean_diff_allowed, max_diff_allowed)

return


def _bfs(root_node, process_node):
"""
Expand Down Expand Up @@ -280,7 +278,6 @@ def _process_layer_parameters(layer):
warnings.warn('No handling for layer %s of type %s, should we ignore it?', layer.name,
layer.type)

return

def _process_layer_output(caffe_blob_name):

Expand Down Expand Up @@ -332,8 +329,6 @@ def _process_layer_output(caffe_blob_name):
for caffe_blob_name in caffe_net.blobs.keys():
_process_layer_output(caffe_blob_name)

return


def main():
"""Entrypoint for compare_layers"""
Expand Down
2 changes: 0 additions & 2 deletions tools/caffe_converter/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ def test_model_weights_and_outputs(model_name, image_url, gpu):
convert_and_compare_caffe_to_mxnet(image_url, gpu, prototxt, caffemodel, mean,
mean_diff_allowed=1e-03, max_diff_allowed=1e-01)

return


def main():
"""Entrypoint for test_converter"""
Expand Down