Skip to content

Commit 1ae24a4

Browse files
authored
Enable docstring ruff checks. NFC (#26806)
1 parent a046aaf commit 1ae24a4

71 files changed

Lines changed: 391 additions & 378 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

em-config.py

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

7-
"""This is a helper tool which is designed to make it possible
8-
for other apps to read emscripten's configuration variables
7+
"""Display emscripten configure file settings.
8+
9+
Helper script which is designed to make it possible for
10+
other apps to read emscripten's configuration variables
911
in a unified way. Usage:
1012
1113
em-config VAR_NAME

emar.py

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

7-
"""Wrapper script around `llvm-ar`.
8-
"""
7+
"""Wrapper script around `llvm-ar`."""
98

109
import sys
1110

emcc.py

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

7-
"""emcc - compiler helper script
7+
"""\
8+
emcc - compiler helper script
89
=============================
910
1011
emcc is a drop-in replacement for a compiler like gcc or clang.
@@ -18,7 +19,7 @@
1819
(by default /tmp/emscripten_temp). "2" will save additional emcc-*
1920
steps, that would normally not be separately produced (so this
2021
slows down compilation).
21-
"""
22+
""" # noqa: D205, D400, D415
2223

2324
import logging
2425
import os
@@ -104,6 +105,7 @@ class LinkFlag:
104105
105106
A list of these is returned by separate_linker_flags.
106107
"""
108+
107109
value: str
108110
is_file: int
109111

@@ -335,7 +337,6 @@ def separate_linker_flags(newargs):
335337
- Linker flags include input files and are returned a list of LinkFlag objects.
336338
- Compiler flags are those to be passed to `clang -c`.
337339
"""
338-
339340
compiler_args = []
340341
linker_args = []
341342

@@ -382,9 +383,7 @@ def get_next_arg():
382383

383384
@ToolchainProfiler.profile_block('setup')
384385
def phase_setup(state):
385-
"""Second phase: configure and setup the compiler based on the specified settings and arguments.
386-
"""
387-
386+
"""Second phase: configure and setup the compiler based on the specified settings and arguments."""
388387
has_header_inputs = any(get_file_suffix(f) in HEADER_EXTENSIONS for f in options.input_files)
389388

390389
if options.post_link:

emconfigure.py

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

7-
"""This is a helper script. It runs ./configure (or cmake,
8-
etc.) for you, setting the environment variables to use
9-
emcc and so forth. Usage:
7+
"""Helper for running ./configure.
8+
9+
This script runs ./configure (or cmake, etc.) for you,
10+
setting the environment variables to use emcc and so forth.
11+
12+
Usage:
1013
1114
emconfigure ./configure [FLAGS]
1215

emmake.py

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

7-
"""This is a helper script. It runs make for you, setting
8-
the environment variables to use emcc and so forth. Usage:
7+
"""Helper script for running make.
8+
9+
This script runs make with correct environment
10+
variables to use emcc and so forth. Usage:
911
1012
emmake make [FLAGS]
1113

emranlib.py

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

7-
"""emranlib - ranlib helper script
7+
"""emranlib - ranlib helper script.
88
99
This script acts as a frontend replacement for ranlib, and simply invokes
1010
llvm-ranlib internally.

emrun.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
# suppress these upgrade warnings:
99
# ruff: noqa: UP015, UP024, UP021, UP025
1010

11-
"""emrun: Implements machinery that allows running a .html page as if it was a
12-
standard executable file.
11+
"""emrun: Tool for running an .html page as if it was a standard executable file.
1312
1413
Usage: emrun <options> filename.html <args to program>
1514
@@ -136,8 +135,7 @@ def tick():
136135

137136

138137
def logi(msg):
139-
"""Prints a log message to 'info' stdout channel. Always printed.
140-
"""
138+
"""Prints a log message to 'info' stdout channel. Always printed."""
141139
global last_message_time
142140
with http_mutex:
143141
sys.stdout.write(msg + '\n')
@@ -147,6 +145,7 @@ def logi(msg):
147145

148146
def logv(msg):
149147
"""Prints a verbose log message to stdout channel.
148+
150149
Only shown if run with --verbose.
151150
"""
152151
global last_message_time
@@ -158,8 +157,7 @@ def logv(msg):
158157

159158

160159
def loge(msg):
161-
"""Prints an error message to stderr channel.
162-
"""
160+
"""Prints an error message to stderr channel."""
163161
global last_message_time
164162
with http_mutex:
165163
sys.stderr.write(msg + '\n')
@@ -174,8 +172,7 @@ def format_eol(msg):
174172

175173

176174
def browser_logi(msg):
177-
"""Prints a message to the browser stdout output stream.
178-
"""
175+
"""Prints a message to the browser stdout output stream."""
179176
global last_message_time
180177
msg = format_eol(msg)
181178
browser_stdout_handle.write(msg + '\n')
@@ -184,8 +181,7 @@ def browser_logi(msg):
184181

185182

186183
def browser_loge(msg):
187-
"""Prints a message to the browser stderr output stream.
188-
"""
184+
"""Prints a message to the browser stderr output stream."""
189185
global last_message_time
190186
msg = format_eol(msg)
191187
browser_stderr_handle.write(msg + '\n')
@@ -195,7 +191,8 @@ def browser_loge(msg):
195191

196192
def unquote_u(source):
197193
"""Unquotes a unicode string.
198-
(translates ascii-encoded utf string back to utf)
194+
195+
Translates ascii-encoded utf string back to utf.
199196
"""
200197
result = unquote(source)
201198
if '%u' in result:
@@ -207,7 +204,7 @@ def unquote_u(source):
207204

208205

209206
def delete_emrun_safe_firefox_profile():
210-
"""Deletes the temporary created Firefox profile (if one exists)"""
207+
"""Delete the temporary created Firefox profile (if one exists)."""
211208
global temp_firefox_profile_dir
212209
if temp_firefox_profile_dir is not None:
213210
logv('remove_tree("' + temp_firefox_profile_dir + '")')
@@ -329,6 +326,7 @@ def create_emrun_safe_firefox_profile():
329326

330327
def is_browser_process_alive():
331328
"""Returns whether the browser page we spawned is still running.
329+
332330
(note, not perfect atm, in case we are running in detached mode)
333331
"""
334332
# If navigation to the web page has not yet occurred, we behave as if the
@@ -358,8 +356,9 @@ def is_browser_process_alive():
358356

359357

360358
def kill_browser_process():
361-
"""Kills browser_process and processname_killed_atexit. Also removes the
362-
temporary Firefox profile that was created, if one exists.
359+
"""Kills browser_process and processname_killed_atexit.
360+
361+
Also removes the temporary Firefox profile that was created, if one exists.
363362
"""
364363
global browser_process, processname_killed_atexit, current_browser_processes
365364
if browser_process and browser_process.poll() is None:
@@ -443,14 +442,18 @@ def pid_existed(pid):
443442
logv('Was unable to detect the browser process that was spawned by emrun. This may occur if the target page was opened in a tab on a browser process that already existed before emrun started up.')
444443

445444

446-
# Our custom HTTP web server that will serve the target page to run via .html.
447-
# This is used so that we can load the page via a http:// URL instead of a
448-
# file:// URL, since those wouldn't work too well unless user allowed XHR
449-
# without CORS rules. Also, the target page will route its stdout and stderr
450-
# back to here via HTTP requests.
451445
class HTTPWebServer(socketserver.ThreadingMixIn, HTTPServer):
452-
"""Log messaging arriving via HTTP can come in out of sequence. Implement a
453-
sequencing mechanism to enforce ordered transmission."""
446+
"""HTTP Server used to serve the target page to run via .html.
447+
448+
This is used so that we can load the page via a http:// URL instead of a
449+
file:// URL, since those wouldn't work too well unless user allowed XHR
450+
without CORS rules. Also, the target page will route its stdout and stderr
451+
back to here via HTTP requests.
452+
453+
Log messaging arriving via HTTP can come in out of sequence. Implement a
454+
sequencing mechanism to enforce ordered transmission.
455+
"""
456+
454457
expected_http_seq_num = 1
455458
# Stores messages that have arrived out of order, pending for a send as soon
456459
# as the missing message arrives. Kept in sorted order, first element is the

emscan-deps.py

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

7-
"""emscan-deps - clang-scan-deps helper script
7+
"""emscan-deps - clang-scan-deps helper script.
88
99
This script acts as a frontend replacement for clang-scan-deps.
1010
"""

emscons.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env python3
2-
"""Wrapping the scons invocation, EMSCRIPTEN_TOOL_PATH is set in the process
3-
environment, and can be used to locate the emscripten SCons Tool.
2+
"""Wrapper for the scons invocation.
43
5-
Example:
4+
EMSCRIPTEN_TOOL_PATH is set in the process environment, and can be used to
5+
locate the emscripten SCons Tool.
66
7+
Example:
78
# Load emscripten Tool
89
my_env = Environment(tools=['emscripten'], toolpath=[os.environ['EMSCRIPTEN_TOOL_PATH']])
10+
911
"""
1012

1113
import os

emsize.py

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

7-
"""Size helper script
7+
"""Size helper script.
88
99
This script acts as a frontend replacement for `size` that supports combining
1010
JS and wasm output from emscripten.

0 commit comments

Comments
 (0)