Skip to content

Commit

Permalink
Fix warnings from latest flake8. NFC (emscripten-core#20574)
Browse files Browse the repository at this point in the history
I'm having trouble upgrading to the latest version of flake8 but
we can at least fix the warnings it reports.
  • Loading branch information
sbc100 authored Oct 30, 2023
1 parent 43479ae commit c551d53
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions emrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def get_cpu_info():
all_info = check_output(['cat', '/proc/cpuinfo']).strip()
for line in all_info.split("\n"):
if 'model name' in line:
cpu_name = re.sub('.*model name.*:', '', line, 1).strip()
cpu_name = re.sub('.*model name.*:', '', line, count=1).strip()
lscpu = check_output(['lscpu'])
frequency = int(float(re.search('CPU MHz: (.*)', lscpu).group(1).strip()) + 0.5)
sockets = int(re.search(r'Socket\(s\): (.*)', lscpu).group(1).strip())
Expand Down Expand Up @@ -1298,7 +1298,7 @@ def list_pc_browsers():
logi('')
for browser in browsers:
browser_exe = find_browser(browser)
if type(browser_exe) == list:
if type(browser_exe) is list:
browser_exe = browser_exe[0]
if browser_exe:
logi(' - ' + browser + ': ' + browser_display_name(browser_exe) + ' ' + get_executable_version(browser_exe))
Expand Down
6 changes: 3 additions & 3 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ def get_setting(self, key, default=None):
def set_setting(self, key, value=1):
if value is None:
self.clear_setting(key)
if type(value) == bool:
if type(value) is bool:
value = int(value)
self.settings_mods[key] = value

Expand All @@ -890,7 +890,7 @@ def serialize_settings(self):
for key, value in self.settings_mods.items():
if value == 1:
ret.append(f'-s{key}')
elif type(value) == list:
elif type(value) is list:
ret.append(f'-s{key}={",".join(value)}')
else:
ret.append(f'-s{key}={value}')
Expand Down Expand Up @@ -1221,7 +1221,7 @@ def assertContained(self, values, string, additional_info='', regex=False):
string = string()

if regex:
if type(values) == str:
if type(values) is str:
self.assertTrue(re.search(values, string), 'Expected regex "%s" to match on:\n%s' % (values, string))
else:
match_any = any(re.search(o, string) for o in values)
Expand Down
2 changes: 1 addition & 1 deletion test/jsrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def run_js(filename, engine, args=None,
"""Execute javascript code generated by tests, with possible timeout."""

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

if not os.path.exists(filename):
raise Exception('output file not found: ' + filename)
Expand Down
2 changes: 1 addition & 1 deletion tools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def check_type(self, name, value):
value = bool(value)
if value in ('True', 'False', 'true', 'false'):
exit_with_error('attempt to set `%s` to `%s`; use 1/0 to set boolean settings' % (name, value))
if type(value) != expected_type:
if type(value) is not expected_type:
exit_with_error('setting `%s` expects `%s` but got `%s`' % (name, expected_type.__name__, type(value).__name__))

def __getitem__(self, key):
Expand Down
2 changes: 1 addition & 1 deletion tools/webidl_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def add_bounds_check_impl():
js_impl_methods: List[str] = []

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

js_impl = interface.getExtendedAttribute('JSImplementation')
Expand Down

0 comments on commit c551d53

Please sign in to comment.