From: Ben Darnell Date: Wed, 12 Jun 2024 01:20:20 +0000 (-0400) Subject: lint: Update flake8 and friends X-Git-Tag: v6.5.0b1~51^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3400%2Fhead;p=thirdparty%2Ftornado.git lint: Update flake8 and friends Use "is" instead of "==" for type comparisons. --- diff --git a/requirements.txt b/requirements.txt index 8dcc978d..5c0326a1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,7 +36,7 @@ filelock==3.12.0 # via # tox # virtualenv -flake8==6.0.0 +flake8==7.0.0 # via -r requirements.in idna==3.7 # via requests @@ -72,9 +72,9 @@ platformdirs==3.5.1 # virtualenv pluggy==1.0.0 # via tox -pycodestyle==2.10.0 +pycodestyle==2.11.1 # via flake8 -pyflakes==3.0.1 +pyflakes==3.2.0 # via flake8 pygments==2.15.0 # via sphinx diff --git a/tornado/options.py b/tornado/options.py index b8296691..cb66b771 100644 --- a/tornado/options.py +++ b/tornado/options.py @@ -427,8 +427,8 @@ class OptionParser(object): % (option.name, option.type.__name__) ) - if type(config[name]) == str and ( - option.type != str or option.multiple + if type(config[name]) is str and ( + option.type is not str or option.multiple ): option.parse(config[name]) else: diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index ecd72635..351a2a89 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -516,16 +516,16 @@ class EchoHandler(RequestHandler): # In httpserver.py (i.e. self.request.arguments), they're left # as bytes. Keys are always native strings. for key in self.request.arguments: - if type(key) != str: + if type(key) is not str: raise Exception("incorrect type for key: %r" % type(key)) for bvalue in self.request.arguments[key]: - if type(bvalue) != bytes: + if type(bvalue) is not bytes: raise Exception("incorrect type for value: %r" % type(bvalue)) for svalue in self.get_arguments(key): - if type(svalue) != unicode_type: + if type(svalue) is not unicode_type: raise Exception("incorrect type for value: %r" % type(svalue)) for arg in path_args: - if type(arg) != unicode_type: + if type(arg) is not unicode_type: raise Exception("incorrect type for path arg: %r" % type(arg)) self.write( dict( @@ -630,7 +630,7 @@ class TypeCheckHandler(RequestHandler): class DecodeArgHandler(RequestHandler): def decode_argument(self, value, name=None): - if type(value) != bytes: + if type(value) is not bytes: raise Exception("unexpected type for value: %r" % type(value)) # use self.request.arguments directly to avoid recursion if "encoding" in self.request.arguments: @@ -640,9 +640,9 @@ class DecodeArgHandler(RequestHandler): def get(self, arg): def describe(s): - if type(s) == bytes: + if type(s) is bytes: return ["bytes", native_str(binascii.b2a_hex(s))] - elif type(s) == unicode_type: + elif type(s) is unicode_type: return ["unicode", s] raise Exception("unknown type")