From 10b24fb663d9dddfb73f7fe20d490e98b23c8bb8 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Tue, 11 Jun 2024 21:20:20 -0400 Subject: [PATCH] lint: Update flake8 and friends Use "is" instead of "==" for type comparisons. --- requirements.txt | 6 +++--- tornado/options.py | 4 ++-- tornado/test/web_test.py | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8dcc978d32..5c0326a1e3 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 b82966910b..cb66b77114 100644 --- a/tornado/options.py +++ b/tornado/options.py @@ -427,8 +427,8 @@ def parse_config_file(self, path: str, final: bool = True) -> None: % (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 ecd7263566..351a2a8971 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -516,16 +516,16 @@ def get(self, *path_args): # 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 @@ def check_type(self, name, obj, expected_type): 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 @@ def decode_argument(self, value, name=None): 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")