Repository: chainer/chainer

Issue:
flake8 warns F632 (use ==/!= to compare str)
```
chainer/variable.py:1781:16: F632 use ==/!= to compare str, bytes, and int literals
chainer/variable.py:1783:18: F632 use ==/!= to compare str, bytes, and int literals
chainer/functions/math/sparse_matmul.py:27:12: F632 use ==/!= to compare str, bytes, and int literals
chainer/functions/math/sparse_matmul.py:29:14: F632 use ==/!= to compare str, bytes, and int literals
chainer/functions/math/sparse_matmul.py:102:8: F632 use ==/!= to compare str, bytes, and int literals
tests/chainer_tests/iterators_tests/test_multiprocess_iterator.py:678:44: F632 use ==/!= to compare str, bytes, and int literals
```


Discussion:
`setup.py` in Chainer specifies `'flake8>=3.6,<3.7'`.  F632 seems warned by `flake8>=3.7`.


Resolving patch:
diff --git a/chainer/functions/math/sparse_matmul.py b/chainer/functions/math/sparse_matmul.py
--- a/chainer/functions/math/sparse_matmul.py
+++ b/chainer/functions/math/sparse_matmul.py
@@ -24,9 +24,9 @@ def _coo_matmul(sp_data, sp_row, sp_col, sp_shape, sp_order,
         A_row = sp_col
         A_col = sp_row
         A_shape = (sp_shape[1], sp_shape[0])
-        if sp_order is 'C':
+        if sp_order == 'C':
             A_order = 'F'
-        elif sp_order is 'F':
+        elif sp_order == 'F':
             A_order = 'C'
         else:
             A_order = sp_order
@@ -99,7 +99,7 @@ def _coo_matmul_gpu(A_data, A_row, A_col, A_shape, A_order, B, dtype):
         nb = B.shape[0]
         C = cuda.cupy.zeros((nb, _m, _n), dtype=cupy_dtype)
 
-    if A_order is 'C':
+    if A_order == 'C':
         # A chunk is the number of non-zero elements handled by a single GPU
         # thread. If contiguous non-zero elemets are related to the same
         # location of the output matrix and they are processed in the same
diff --git a/chainer/variable.py b/chainer/variable.py
--- a/chainer/variable.py
+++ b/chainer/variable.py
@@ -1787,9 +1787,9 @@ def from_chx(self):
 
         if isinstance(device, backend.ChainerxDevice):
             backend_name = device.device.backend.name
-            if backend_name is 'native':
+            if backend_name == 'native':
                 self._initial_device = backend.CpuDevice()
-            elif backend_name is 'cuda':
+            elif backend_name == 'cuda':
                 self._initial_device = chainer.get_device(
                     (cuda.cupy, device.device.index))
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -33,9 +33,8 @@
     ],
     'stylecheck': [
         'autopep8>=1.4.1,<1.5',
-        'flake8>=3.6,<3.7',
-        'pbr==4.0.4',
-        'pycodestyle>=2.4,<2.5',
+        'flake8>=3.7,<3.8',
+        'pycodestyle>=2.5,<2.6',
     ],
     'test': [
         'pytest==4.1.1',  # 4.2.0 is slow collecting tests and times out on CI.


Test patch:
diff --git a/tests/chainer_tests/iterators_tests/test_multiprocess_iterator.py b/tests/chainer_tests/iterators_tests/test_multiprocess_iterator.py
--- a/tests/chainer_tests/iterators_tests/test_multiprocess_iterator.py
+++ b/tests/chainer_tests/iterators_tests/test_multiprocess_iterator.py
@@ -675,7 +675,7 @@ def __getitem__(self, _):
         os.write(fd, six.b(code))
         os.close(fd)
 
-        if self.shared_mem is not None and dataset is 'infinite_wait':
+        if self.shared_mem is not None and dataset == 'infinite_wait':
             stdout = subprocess.PIPE
         else:
             stdout = None
diff --git a/tests/chainer_tests/optimizers_tests/test_optimizers_by_linear_model.py b/tests/chainer_tests/optimizers_tests/test_optimizers_by_linear_model.py
--- a/tests/chainer_tests/optimizers_tests/test_optimizers_by_linear_model.py
+++ b/tests/chainer_tests/optimizers_tests/test_optimizers_by_linear_model.py
@@ -96,9 +96,9 @@ def _optimizer_loss_scaling(optimizer, loss_scaling):
     if loss_scaling not in [False, 'dynamic', 'static']:
         msg = 'loss_scaling must be False, \'dynamic\' or \'static\'.'
         raise ValueError(msg)
-    if loss_scaling is 'dynamic':
+    if loss_scaling == 'dynamic':
         optimizer.loss_scaling()
-    elif loss_scaling is 'static':
+    elif loss_scaling == 'static':
         optimizer.loss_scaling(scale=10.0)