Skip to content

Commit

Permalink
Enable E0611, but disable only for tensorflow.python
Browse files Browse the repository at this point in the history
E0611 will incorrectly flag tensorflow.python due to a pylint bug [0].
Thus, we need to add inline disabling for this import.

[0] pylint-dev/pylint#1524 (comment)
  • Loading branch information
redshiftzero committed Dec 1, 2018
1 parent 8942bea commit 9b20906
Show file tree
Hide file tree
Showing 26 changed files with 31 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'
# In many cases we use all arguments via `locals()` and pylint does not
# detect them as used.
# E1101: pylint seems to have a bug. Says numpy.random has no member RandomState
# E0611: pylint seems to have a bug. Complains about imports of tensorflow
# R0913: Too many arguments
# R0914: Too many local variables
# W0223: doesn't allow subclass of an abstract base class to still be abstract
Expand Down Expand Up @@ -99,4 +98,4 @@ msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'
# R1714: use x in [a,b] instead of x == a or x == b
# R0801: duplicate code across files
# (We have a lot of intentional duplication, like the tutorials)
disable=C0103,C0111,W0613,E1101,E0611,R0913,R0914,W0223,E0203,W0201,C1801,E1129,C0325,R1705,W0622,W0703,W0101,W0122,R0912,R0903,W0221,W0212,R1703,R0201,W0603,R0915,R0902,C0200,W1201,C0302,W0511,R0911,E0401,R0205,R1714,R0801,E1130
disable=C0103,C0111,W0613,E1101,R0913,R0914,W0223,E0203,W0201,C1801,E1129,C0325,R1705,W0622,W0703,W0101,W0122,R0912,R0903,W0221,W0212,R1703,R0201,W0603,R0915,R0902,C0200,W1201,C0302,W0511,R0911,E0401,R0205,R1714,R0801,E1130
3 changes: 3 additions & 0 deletions cleverhans/devtools/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def test_format_pep8():
# a benefit to not being blocked on I/O.

try:
print(rcpath)
#if 'cleverhans/attacks/__init__.py' in files_to_check:
# import pdb; pdb.set_trace()
shell_call(['pylint', '--rcfile', rcpath, '--jobs', '8'] + files_to_check)
except subprocess.CalledProcessError as e:
raise ValueError(e.output.decode("utf-8"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import logging

import tensorflow as tf
from tensorflow.python.platform import app, flags
from tensorflow.python.platform import app, flags # pylint: disable=no-name-in-module
from cleverhans.utils import set_log_level, to_categorical, safe_zip
from cleverhans.utils_tf import model_eval
from cleverhans import serial
Expand Down
2 changes: 1 addition & 1 deletion cleverhans/utils_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import six
from six.moves import xrange
import tensorflow as tf
from tensorflow.python.client import device_lib
from tensorflow.python.client import device_lib # pylint: disable=no-name-in-module

from cleverhans.compat import reduce_sum, reduce_mean
from cleverhans.compat import reduce_max
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/cifar10_tutorial_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import logging
import numpy as np
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.attacks import FastGradientMethod
from cleverhans.augmentation import random_horizontal_flip, random_shift
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/evaluate_pickled_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import logging

import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.dataset import MNIST
from cleverhans.attacks import FastGradientMethod
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/mnist_blackbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import numpy as np
from six.moves import xrange
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.attacks import FastGradientMethod
from cleverhans.attacks_tf import jacobian_graph, jacobian_augmentation
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/mnist_tutorial_cw.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import os
import numpy as np
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.attacks import CarliniWagnerL2
from cleverhans.dataset import MNIST
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/mnist_tutorial_jsma.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
from six.moves import xrange
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.attacks import SaliencyMapMethod
from cleverhans.dataset import MNIST
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/mnist_tutorial_keras_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import os

import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module
import numpy as np
import keras
from keras import backend
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/mnist_tutorial_picklable.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import logging
import numpy as np
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.attacks import FastGradientMethod
from cleverhans.dataset import MNIST
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/mnist_tutorial_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import numpy as np
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module
import torch
from torch import nn
import torch.nn.functional as F
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/mnist_tutorial_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import logging
import numpy as np
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.loss import CrossEntropy
from cleverhans.dataset import MNIST
Expand Down
2 changes: 1 addition & 1 deletion cleverhans_tutorials/mnist_tutorial_tfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import logging
import numpy as np
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.utils import AccuracyReport
from cleverhans.utils_tfe import train, model_eval
Expand Down
4 changes: 2 additions & 2 deletions examples/imagenet_featadvs/attack_model_featadv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import numpy as np

import tensorflow as tf
from tensorflow.python.platform import app
from tensorflow.python.platform import flags
from tensorflow.python.platform import app # pylint: disable=no-name-in-module
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.attacks import FastFeatureAdversaries
from model import make_imagenet_cnn
Expand Down
2 changes: 1 addition & 1 deletion examples/madry_lab_challenges/cifar10/attack_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import logging

import tensorflow as tf
from tensorflow.python.platform import app, flags
from tensorflow.python.platform import app, flags # pylint: disable=no-name-in-module
from cleverhans.utils import set_log_level, to_categorical
from cleverhans.utils_tf import model_eval
import cifar10_input
Expand Down
4 changes: 2 additions & 2 deletions examples/madry_lab_challenges/mnist/attack_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
from tensorflow.python.platform import app
from tensorflow.python.platform import flags
from tensorflow.python.platform import app # pylint: disable=no-name-in-module
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module
from madry_mnist_model import MadryMNIST
from cleverhans.utils_tf import model_eval
from cleverhans.attacks import FastGradientMethod
Expand Down
4 changes: 2 additions & 2 deletions examples/multigpu_advtrain/run_multigpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import logging
from collections import namedtuple

from tensorflow.python.platform import app
from tensorflow.python.platform import flags
from tensorflow.python.platform import app # pylint: disable=no-name-in-module
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module


from trainer import TrainerMultiGPU
Expand Down
2 changes: 1 addition & 1 deletion scripts/compute_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import time

import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.attacks import ProjectedGradientDescent, Semantic
from cleverhans.evaluation import accuracy
Expand Down
2 changes: 1 addition & 1 deletion scripts/make_confidence_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from __future__ import unicode_literals

import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.utils_tf import silence
silence()
Expand Down
2 changes: 1 addition & 1 deletion scripts/make_confidence_report_bundle_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import numpy as np
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.utils_tf import silence
# We need to disable pylint's complaints about import order because `silence`
Expand Down
2 changes: 1 addition & 1 deletion scripts/make_confidence_report_bundled.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from __future__ import unicode_literals

import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.utils_tf import silence
# The silence() call must precede other imports in order to silence them.
Expand Down
2 changes: 1 addition & 1 deletion scripts/make_confidence_report_spsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import numpy as np
import tensorflow as tf
from tensorflow.python.platform import flags
from tensorflow.python.platform import flags # pylint: disable=no-name-in-module

from cleverhans.utils_tf import silence
silence()
Expand Down
2 changes: 1 addition & 1 deletion tests_tf/test_mnist_blackbox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
import numpy as np
from tensorflow.python.client import device_lib
from tensorflow.python.client import device_lib # pylint: disable=no-name-in-module
from cleverhans.devtools.checks import CleverHansTest

HAS_GPU = 'GPU' in set(
Expand Down
2 changes: 1 addition & 1 deletion tests_tf/test_mnist_tutorial_keras_tf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
import numpy as np
from tensorflow.python.client import device_lib
from tensorflow.python.client import device_lib # pylint: disable=no-name-in-module
from cleverhans.devtools.checks import CleverHansTest

HAS_GPU = 'GPU' in set(
Expand Down
2 changes: 1 addition & 1 deletion tests_tf/test_mnist_tutorial_tf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
import numpy as np
from tensorflow.python.client import device_lib
from tensorflow.python.client import device_lib # pylint: disable=no-name-in-module
from cleverhans.devtools.checks import CleverHansTest

HAS_GPU = 'GPU' in set(
Expand Down

0 comments on commit 9b20906

Please sign in to comment.