Skip to content

Commit 8f0ffae

Browse files
committed
make ruff happy
1 parent 731248b commit 8f0ffae

File tree

24 files changed

+82
-301
lines changed

24 files changed

+82
-301
lines changed

docs/source/_exts/build_custom_js.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99

1010
def setup(app: Sphinx) -> None:
11-
subprocess.run("npm install", cwd=CUSTOM_JS_DIR, shell=True)
12-
subprocess.run("npm run build", cwd=CUSTOM_JS_DIR, shell=True)
11+
subprocess.run("npm install", cwd=CUSTOM_JS_DIR, shell=True) # noqa S607
12+
subprocess.run("npm run build", cwd=CUSTOM_JS_DIR, shell=True) # noqa S607

docs/source/guides/managing-state/sharing-component-state/_examples/filterable_list/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ def Table(value, set_value):
3434
tr = html.tr(name, descr, value)
3535
if not value:
3636
rows.append(tr)
37-
else:
38-
if value.lower() in row["name"].lower():
39-
rows.append(tr)
37+
elif value.lower() in row["name"].lower():
38+
rows.append(tr)
4039
headers = html.tr(html.td(html.b("name")), html.td(html.b("description")))
4140
table = html.table(html.thead(headers), html.tbody(rows))
4241
return table

docs/source/reference/_examples/pigeon_maps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def MapWithMarkers():
1212
Marker(
1313
{
1414
"anchor": anchor,
15-
"onClick": lambda: remove_marker_anchor(anchor),
15+
"onClick": lambda event, a=anchor: remove_marker_anchor(a),
1616
},
1717
key=str(anchor),
1818
)

pyproject.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ select = [
3939
"C",
4040
"DTZ",
4141
"E",
42-
"EM",
42+
# error message linting is overkill
43+
# "EM",
4344
"F",
4445
# TODO: turn this on later
4546
# "FBT",
@@ -63,14 +64,22 @@ select = [
6364
ignore = [
6465
# TODO: turn this on later
6566
"N802", "N806", # allow TitleCase functions/variables
67+
# We're not any cryptography
68+
"S311",
69+
# For loop variable re-assignment seems like an uncommon mistake
70+
"PLW2901",
6671
# Let Black deal with line-length
6772
"E501",
73+
# Allow args/attrs to shadow built-ins
74+
"A002", "A003",
6875
# Allow unused args (useful for documenting what the parameter is for later)
69-
"ARG001", "ARG005",
76+
"ARG001", "ARG002", "ARG005",
7077
# Allow non-abstract empty methods in abstract base classes
7178
"B027",
7279
# Allow boolean positional values in function calls, like `dict.get(... True)`
7380
"FBT003",
81+
# If we're making an explicit comparison to a falsy value it was probably intentional
82+
"PLC1901",
7483
# Ignore checks for possible passwords
7584
"S105", "S106", "S107",
7685
# Ignore complexity

scripts/live_docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def main():
8686
ignore_handler = _get_ignore_handler(args)
8787
server.watch(srcdir, builder, ignore=ignore_handler)
8888
for dirpath in args.additional_watched_dirs:
89-
dirpath = os.path.realpath(dirpath)
90-
server.watch(dirpath, builder, ignore=ignore_handler)
89+
real_dirpath = os.path.realpath(dirpath)
90+
server.watch(real_dirpath, builder, ignore=ignore_handler)
9191
server.watch(outdir, ignore=ignore_handler)
9292

9393
if not args.no_initial_build:

scripts/run_docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
# to import docs
66
sys.path.insert(0, os.getcwd())
77

8-
from docs.app import make_app
8+
from docs.app import make_app # noqa: E402
99

1010
app = make_app()
1111

1212
if __name__ == "__main__":
1313
app.run(
14-
host="0.0.0.0",
14+
host="0.0.0.0", # noqa: S104
1515
port=int(os.environ.get("PORT", 5000)),
1616
workers=int(os.environ.get("WEB_CONCURRENCY", 1)),
1717
debug=bool(int(os.environ.get("DEBUG", "0"))),

src/py/reactpy/reactpy/_console/ast_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def find_element_constructor_usages(
129129
node.args.insert(1, maybe_attr_dict_node)
130130
else:
131131
continue
132-
elif len(node.args) >= 2:
132+
elif len(node.args) >= 2: # noqa: PLR2004
133133
maybe_attr_dict_node = node.args[1]
134134
elif hasattr(html, name):
135135
if len(node.args) == 0:

src/py/reactpy/reactpy/_warnings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def warn(*args: Any, **kwargs: Any) -> Any:
1313

1414

1515
if TYPE_CHECKING:
16-
warn = _warn
16+
warn = _warn # noqa F811
1717

1818

1919
def _frame_depth_in_module() -> int:

src/py/reactpy/reactpy/backend/default.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def serve_development_app(
5050

5151
def _default_implementation() -> BackendImplementation[Any]:
5252
"""Get the first available server implementation"""
53-
global _DEFAULT_IMPLEMENTATION
53+
global _DEFAULT_IMPLEMENTATION # noqa PLW0603
5454

5555
if _DEFAULT_IMPLEMENTATION is not None:
5656
return _DEFAULT_IMPLEMENTATION
@@ -60,7 +60,7 @@ def _default_implementation() -> BackendImplementation[Any]:
6060
except StopIteration: # pragma: no cover
6161
logger.debug("Backend implementation import failed", exc_info=exc_info())
6262
msg = "No built-in server implementation installed."
63-
raise RuntimeError(msg)
63+
raise RuntimeError(msg) from None
6464
else:
6565
_DEFAULT_IMPLEMENTATION = implementation
6666
return implementation

src/py/reactpy/reactpy/backend/flask.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ async def main() -> None:
256256

257257
dispatch_thread_info_created.wait()
258258
dispatch_thread_info = cast(_DispatcherThreadInfo, dispatch_thread_info_ref.current)
259-
assert dispatch_thread_info is not None
259+
260+
if dispatch_thread_info is None:
261+
raise RuntimeError("Failed to create dispatcher thread")
260262

261263
stop = ThreadEvent()
262264

0 commit comments

Comments
 (0)