Skip to content

Commit c551d53

Browse files
authored
Fix warnings from latest flake8. NFC (emscripten-core#20574)
I'm having trouble upgrading to the latest version of flake8 but we can at least fix the warnings it reports.
1 parent 43479ae commit c551d53

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

emrun.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ def get_cpu_info():
770770
all_info = check_output(['cat', '/proc/cpuinfo']).strip()
771771
for line in all_info.split("\n"):
772772
if 'model name' in line:
773-
cpu_name = re.sub('.*model name.*:', '', line, 1).strip()
773+
cpu_name = re.sub('.*model name.*:', '', line, count=1).strip()
774774
lscpu = check_output(['lscpu'])
775775
frequency = int(float(re.search('CPU MHz: (.*)', lscpu).group(1).strip()) + 0.5)
776776
sockets = int(re.search(r'Socket\(s\): (.*)', lscpu).group(1).strip())
@@ -1298,7 +1298,7 @@ def list_pc_browsers():
12981298
logi('')
12991299
for browser in browsers:
13001300
browser_exe = find_browser(browser)
1301-
if type(browser_exe) == list:
1301+
if type(browser_exe) is list:
13021302
browser_exe = browser_exe[0]
13031303
if browser_exe:
13041304
logi(' - ' + browser + ': ' + browser_display_name(browser_exe) + ' ' + get_executable_version(browser_exe))

test/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ def get_setting(self, key, default=None):
875875
def set_setting(self, key, value=1):
876876
if value is None:
877877
self.clear_setting(key)
878-
if type(value) == bool:
878+
if type(value) is bool:
879879
value = int(value)
880880
self.settings_mods[key] = value
881881

@@ -890,7 +890,7 @@ def serialize_settings(self):
890890
for key, value in self.settings_mods.items():
891891
if value == 1:
892892
ret.append(f'-s{key}')
893-
elif type(value) == list:
893+
elif type(value) is list:
894894
ret.append(f'-s{key}={",".join(value)}')
895895
else:
896896
ret.append(f'-s{key}={value}')
@@ -1221,7 +1221,7 @@ def assertContained(self, values, string, additional_info='', regex=False):
12211221
string = string()
12221222

12231223
if regex:
1224-
if type(values) == str:
1224+
if type(values) is str:
12251225
self.assertTrue(re.search(values, string), 'Expected regex "%s" to match on:\n%s' % (values, string))
12261226
else:
12271227
match_any = any(re.search(o, string) for o in values)

test/jsrun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def run_js(filename, engine, args=None,
9090
"""Execute javascript code generated by tests, with possible timeout."""
9191

9292
# We used to support True here but we no longer do. Assert here just in case.
93-
assert type(assert_returncode) == int
93+
assert type(assert_returncode) is int
9494

9595
if not os.path.exists(filename):
9696
raise Exception('output file not found: ' + filename)

tools/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def check_type(self, name, value):
239239
value = bool(value)
240240
if value in ('True', 'False', 'true', 'false'):
241241
exit_with_error('attempt to set `%s` to `%s`; use 1/0 to set boolean settings' % (name, value))
242-
if type(value) != expected_type:
242+
if type(value) is not expected_type:
243243
exit_with_error('setting `%s` expects `%s` but got `%s`' % (name, expected_type.__name__, type(value).__name__))
244244

245245
def __getitem__(self, key):

tools/webidl_binder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ def add_bounds_check_impl():
655655
js_impl_methods: List[str] = []
656656

657657
cons = interface.getExtendedAttribute('Constructor')
658-
if type(cons) == list:
658+
if type(cons) is list:
659659
raise Exception('do not use "Constructor", instead create methods with the name of the interface')
660660

661661
js_impl = interface.getExtendedAttribute('JSImplementation')

0 commit comments

Comments
 (0)