Skip to content

Commit 03a9c7e

Browse files
authored
Enable UP ruff checks and fix resulting warnings. NFC (#24198)
1 parent 1d262cc commit 03a9c7e

24 files changed

+48
-42
lines changed

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def run(args):
535535
# read response files very early on
536536
try:
537537
args = substitute_response_files(args)
538-
except IOError as e:
538+
except OSError as e:
539539
exit_with_error(e)
540540

541541
if '--help' in args:

emrun.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# University of Illinois/NCSA Open Source License. Both these licenses can be
55
# found in the LICENSE file.
66

7+
# This file needs to run on older version of python too (even python 2!) so
8+
# suppress these upgrade warnings:
9+
# ruff: noqa: UP015, UP024, UP021, UP025
10+
711
"""emrun: Implements machinery that allows running a .html page as if it was a
812
standard executable file.
913

emsymbolizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Error(BaseException):
3131

3232

3333
# Class to treat location info in a uniform way across information sources.
34-
class LocationInfo(object):
34+
class LocationInfo:
3535
def __init__(self, source=None, line=0, column=0, func=None):
3636
self.source = source
3737
self.line = line
@@ -98,8 +98,8 @@ def get_sourceMappingURL_section(module):
9898
return None
9999

100100

101-
class WasmSourceMap(object):
102-
class Location(object):
101+
class WasmSourceMap:
102+
class Location:
103103
def __init__(self, source=None, line=0, column=0, func=None):
104104
self.source = source
105105
self.line = line

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[project]
2+
requires-python = ">=3.8"
3+
14
[tool.ruff]
25
exclude = [
36
"./cache/",
@@ -22,6 +25,7 @@ lint.select = [
2225
"PERF",
2326
"PIE",
2427
"PL",
28+
"UP",
2529
"W",
2630
"YTT",
2731
]
@@ -42,6 +46,9 @@ lint.ignore = [
4246
"PLW0603",
4347
"PLW1510",
4448
"PLW2901",
49+
"UP030", # TODO
50+
"UP031", # TODO
51+
"UP032", # TODO
4552
]
4653
lint.per-file-ignores."emrun.py" = [ "PLE0704" ]
4754
lint.per-file-ignores."tools/ports/*.py" = [ "ARG001", "ARG005" ]

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
coverage[toml]==6.5
88
mypy==1.14
9-
ruff==0.11.4
9+
ruff==0.11.7
1010
types-requests==2.32.0.20241016
1111
unittest-xml-reporting==3.2.0
1212

site/source/get_api_items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def addapiitems(matchobj):
6565
filepath = api_reference_directory + file
6666
print(file)
6767
# open file
68-
with open(filepath, 'r') as infile:
68+
with open(filepath) as infile:
6969
for line in infile:
7070
# parse line for API items
7171
re.sub(r'^\.\.\s+((\w+)\:(\w+)\:\:(.*))', addapiitems, line)

site/source/get_wiki.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def errorhandler(func, path, exc_info):
5757
try:
5858
shutil.rmtree(output_dir, ignore_errors=False, onerror=errorhandler)
5959
print('Old wiki clone removed')
60-
except IOError:
60+
except OSError:
6161
print('No directory to clean found')
6262

6363

system/bin/sdl-config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
22

3-
from __future__ import print_function
43
import sys
54

65
print('emscripten sdl-config called with', ' '.join(sys.argv), file=sys.stderr)

test/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,7 @@ def send_head(self):
20792079
try:
20802080
fsize = os.path.getsize(path)
20812081
f = open(path, 'rb')
2082-
except IOError:
2082+
except OSError:
20832083
self.send_error(404, f'File not found {path}')
20842084
return None
20852085
self.send_response(206)

test/jsrun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def run_js(filename, engine, args=None,
108108
input=input,
109109
cwd=cwd,
110110
timeout=timeout,
111-
universal_newlines=True)
111+
text=True)
112112
except Exception:
113113
# the failure may be because the engine is not present. show the proper
114114
# error in that case

0 commit comments

Comments
 (0)