Skip to content

Commit 3faa10f

Browse files
authored
Try to fix lint (#1157)
* misc * fix lint
1 parent f053551 commit 3faa10f

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

pyproject.toml

+19-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"invoke",
1414
# lint
1515
"black",
16-
"ruff==0.0.278", # Ruff is moving really fast, so pinning for now.
16+
"ruff==0.0.278", # Ruff is moving really fast, so pinning for now.
1717
"toml",
1818
"flake8",
1919
"flake8-pyproject",
@@ -32,9 +32,11 @@ publish = "invoke publish {args}"
3232
docs = "invoke docs {args}"
3333
check = ["lint-py", "lint-js", "test-py", "test-js", "test-docs"]
3434

35+
lint = ["lint-py", "lint-js"]
3536
lint-py = "invoke lint-py {args}"
3637
lint-js = "invoke lint-js {args}"
3738

39+
test = ["test-py", "test-js", "test-docs"]
3840
test-py = "invoke test-py {args}"
3941
test-js = "invoke test-js"
4042
test-docs = "invoke test-docs"
@@ -56,7 +58,7 @@ warn_unused_ignores = true
5658
# --- Flake8 ---------------------------------------------------------------------------
5759

5860
[tool.flake8]
59-
select = ["RPY"] # only need to check with reactpy-flake8
61+
select = ["RPY"] # only need to check with reactpy-flake8
6062
exclude = ["**/node_modules/*", ".eggs/*", ".tox/*", "**/venv/*"]
6163

6264
# --- Ruff -----------------------------------------------------------------------------
@@ -95,27 +97,37 @@ select = [
9597
]
9698
ignore = [
9799
# TODO: turn this on later
98-
"N802", "N806", # allow TitleCase functions/variables
100+
"N802",
101+
"N806", # allow TitleCase functions/variables
99102
# We're not any cryptography
100103
"S311",
101104
# For loop variable re-assignment seems like an uncommon mistake
102105
"PLW2901",
103106
# Let Black deal with line-length
104107
"E501",
105108
# Allow args/attrs to shadow built-ins
106-
"A002", "A003",
109+
"A002",
110+
"A003",
107111
# Allow unused args (useful for documenting what the parameter is for later)
108-
"ARG001", "ARG002", "ARG005",
112+
"ARG001",
113+
"ARG002",
114+
"ARG005",
109115
# Allow non-abstract empty methods in abstract base classes
110116
"B027",
111117
# Allow boolean positional values in function calls, like `dict.get(... True)`
112118
"FBT003",
113119
# If we're making an explicit comparison to a falsy value it was probably intentional
114120
"PLC1901",
115121
# Ignore checks for possible passwords
116-
"S105", "S106", "S107",
122+
"S105",
123+
"S106",
124+
"S107",
117125
# Ignore complexity
118-
"C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915",
126+
"C901",
127+
"PLR0911",
128+
"PLR0912",
129+
"PLR0913",
130+
"PLR0915",
119131
]
120132
unfixable = [
121133
# Don't touch unused imports

src/py/reactpy/reactpy/backend/sanic.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ class Options(CommonOptions):
4848

4949
# BackendType.configure
5050
def configure(
51-
app: Sanic, component: RootComponentConstructor, options: Options | None = None
51+
app: Sanic[Any, Any],
52+
component: RootComponentConstructor,
53+
options: Options | None = None,
5254
) -> None:
5355
"""Configure an application instance to display the given component"""
5456
options = options or Options()
@@ -63,7 +65,7 @@ def configure(
6365

6466

6567
# BackendType.create_development_app
66-
def create_development_app() -> Sanic:
68+
def create_development_app() -> Sanic[Any, Any]:
6769
"""Return a :class:`Sanic` app instance in test mode"""
6870
Sanic.test_mode = True
6971
logger.warning("Sanic.test_mode is now active")
@@ -72,7 +74,7 @@ def create_development_app() -> Sanic:
7274

7375
# BackendType.serve_development_app
7476
async def serve_development_app(
75-
app: Sanic,
77+
app: Sanic[Any, Any],
7678
host: str,
7779
port: int,
7880
started: asyncio.Event | None = None,
@@ -81,7 +83,7 @@ async def serve_development_app(
8183
await serve_with_uvicorn(app, host, port, started)
8284

8385

84-
def use_request() -> request.Request:
86+
def use_request() -> request.Request[Any, Any]:
8587
"""Get the current ``Request``"""
8688
return use_connection().carrier.request
8789

@@ -113,7 +115,7 @@ def _setup_common_routes(
113115
index_html = read_client_index_html(options)
114116

115117
async def single_page_app_files(
116-
request: request.Request,
118+
request: request.Request[Any, Any],
117119
_: str = "",
118120
) -> response.HTTPResponse:
119121
return response.html(index_html)
@@ -131,7 +133,7 @@ async def single_page_app_files(
131133
)
132134

133135
async def asset_files(
134-
request: request.Request,
136+
request: request.Request[Any, Any],
135137
path: str = "",
136138
) -> response.HTTPResponse:
137139
path = urllib_parse.unquote(path)
@@ -140,7 +142,7 @@ async def asset_files(
140142
api_blueprint.add_route(asset_files, f"/{ASSETS_PATH.name}/<path:path>")
141143

142144
async def web_module_files(
143-
request: request.Request,
145+
request: request.Request[Any, Any],
144146
path: str,
145147
_: str = "", # this is not used
146148
) -> response.HTTPResponse:
@@ -159,7 +161,9 @@ def _setup_single_view_dispatcher_route(
159161
options: Options,
160162
) -> None:
161163
async def model_stream(
162-
request: request.Request, socket: WebSocketConnection, path: str = ""
164+
request: request.Request[Any, Any],
165+
socket: WebSocketConnection,
166+
path: str = "",
163167
) -> None:
164168
asgi_app = getattr(request.app, "_asgi_app", None)
165169
scope = asgi_app.transport.scope if asgi_app else {}
@@ -220,7 +224,7 @@ async def sock_recv() -> Any:
220224
class _SanicCarrier:
221225
"""A simple wrapper for holding connection information"""
222226

223-
request: request.Request
227+
request: request.Request[Sanic[Any, Any], Any]
224228
"""The current request object"""
225229

226230
websocket: WebSocketConnection

src/py/reactpy/reactpy/core/layout.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _render_component(
180180
old_parent_model = parent.model.current
181181
old_parent_children = old_parent_model["children"]
182182
parent.model.current = {
183-
**old_parent_model, # type: ignore[misc]
183+
**old_parent_model,
184184
"children": [
185185
*old_parent_children[:index],
186186
new_state.model.current,

0 commit comments

Comments
 (0)