Repository: ckan/ckan

Issue:
use ==/!= to compare str, bytes, and int literals
[flake8](http://flake8.pycqa.org) testing of https://github.com/ckan/ckan on Python 3.7.1

$ __flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics__
```
./ckan/lib/helpers.py:192:18: F632 use ==/!= to compare str, bytes, and int literals
    if uargs and len(uargs) is 1 and isinstance(uargs[0], string_types) \
                 ^
./ckan/plugins/toolkit.py:478:12: F632 use ==/!= to compare str, bytes, and int literals
        if len(endpoint) is 1:
           ^
./ckan/tests/legacy/logic/test_action.py:705:16: F632 use ==/!= to compare str, bytes, and int literals
        assert count is 0
               ^
./ckan/tests/legacy/functional/test_pagination.py:13:8: F632 use ==/!= to compare str, bytes, and int literals
    if object_type is not 'group_dataset':
       ^
4     F632 use ==/!= to compare str, bytes, and int literals
4
```


Discussion:
:+1: to this and using flake8 generally
@cclauss sounds good, want to submit a PR?

Resolving patch:
diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -189,7 +189,7 @@ def redirect_to(*args, **kw):
     _url = ''
     skip_url_parsing = False
     parse_url = kw.pop('parse_url', False)
-    if uargs and len(uargs) is 1 and isinstance(uargs[0], string_types) \
+    if uargs and len(uargs) == 1 and isinstance(uargs[0], string_types) \
             and (uargs[0].startswith('/') or is_url(uargs[0])) \
             and parse_url is False:
         skip_url_parsing = True
diff --git a/ckan/plugins/toolkit.py b/ckan/plugins/toolkit.py
--- a/ckan/plugins/toolkit.py
+++ b/ckan/plugins/toolkit.py
@@ -475,7 +475,7 @@ def _get_endpoint(cls):
         # there are some routes('hello_world') that are not using blueprint
         # For such case, let's assume that view function is a controller
         # itself and action is None.
-        if len(endpoint) is 1:
+        if len(endpoint) == 1:
             return endpoint + (None,)
         return endpoint
 


Test patch:
diff --git a/ckan/tests/legacy/functional/test_pagination.py b/ckan/tests/legacy/functional/test_pagination.py
--- a/ckan/tests/legacy/functional/test_pagination.py
+++ b/ckan/tests/legacy/functional/test_pagination.py
@@ -10,7 +10,7 @@
 
 def scrape_search_results(response, object_type):
     assert object_type in ('dataset', 'group_dataset', 'group', 'user')
-    if object_type is not 'group_dataset':
+    if object_type != 'group_dataset':
         results = re.findall('a href="/%s/%s_(\d\d)' % (object_type, object_type),
                              str(response))
     else:
diff --git a/ckan/tests/legacy/logic/test_action.py b/ckan/tests/legacy/logic/test_action.py
--- a/ckan/tests/legacy/logic/test_action.py
+++ b/ckan/tests/legacy/logic/test_action.py
@@ -702,7 +702,7 @@ def test_42_resource_search_test_percentage_is_escaped(self):
         # There shouldn't be any results.  If the '%' character wasn't
         # escaped correctly, then the search would match because of the
         # unescaped wildcard.
-        assert count is 0
+        assert count == 0
 
     def test_42_resource_search_fields_parameter_still_accepted(self):
         '''The fields parameter is deprecated, but check it still works.