Skip to content

Commit e025f05

Browse files
committed
more ruff fixes
1 parent ffac74a commit e025f05

File tree

74 files changed

+146
-264
lines changed

Some content is hidden

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

74 files changed

+146
-264
lines changed

.github/workflows/.nox-session.yml renamed to .github/workflows/.hatch-run.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
name: Nox Session
1+
name: hatch-run
22

33
on:
44
workflow_call:
55
inputs:
66
job-name:
77
required: true
88
type: string
9-
nox-args:
9+
hatch-run:
1010
required: true
1111
type: string
12-
nox-session-args:
13-
required: false
14-
type: string
1512
runs-on-array:
1613
required: false
1714
type: string
@@ -29,7 +26,7 @@ on:
2926
required: false
3027

3128
jobs:
32-
nox-session:
29+
hatch:
3330
name: ${{ format(inputs.job-name, matrix.python-version, matrix.runs-on) }}
3431
strategy:
3532
matrix:
@@ -55,4 +52,4 @@ jobs:
5552
NODE_AUTH_TOKEN: ${{ secrets.node-auth-token }}
5653
PYPI_USERNAME: ${{ secrets.pypi-username }}
5754
PYPI_PASSWORD: ${{ secrets.pypi-password }}
58-
run: nox ${{ inputs.nox-args }} --stop-on-first-error -- ${{ inputs.nox-session-args }}
55+
run: hatch run ${{ inputs.hatch-run }}

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ on:
1212

1313
jobs:
1414
python-exhaustive:
15-
uses: ./.github/workflows/.nox-session.yml
15+
uses: ./.github/workflows/.hatch-run.yml
1616
with:
1717
job-name: "python-{0}"
18-
nox-args: "-t check-python"
18+
hatch-run: "-t check-python"
1919
nox-session-args: "--pytest --maxfail=3 --reruns 3"
2020
python-environments:
2121
uses: ./.github/workflows/.nox-session.yml
@@ -24,7 +24,7 @@ jobs:
2424
nox-args: "-s check-python-tests"
2525
nox-session-args: "--no-cov --pytest --maxfail=3 --reruns 3"
2626
runs-on-array: '["ubuntu-latest", "macos-latest", "windows-latest"]'
27-
python-version-array: '["3.7", "3.8", "3.9", "3.10", "3.11"]'
27+
python-version-array: '["3.9", "3.10", "3.11"]'
2828
docs:
2929
uses: ./.github/workflows/.nox-session.yml
3030
with:

docs/app.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33

44
from sanic import Sanic, response
55

6+
from docs.examples import get_normalized_example_name, load_examples
67
from reactpy import component
78
from reactpy.backend.sanic import Options, configure, use_request
89
from reactpy.core.types import ComponentConstructor
910

10-
from .examples import get_normalized_example_name, load_examples
11-
12-
1311
HERE = Path(__file__).parent
1412
REACTPY_MODEL_SERVER_URL_PREFIX = "/_reactpy"
1513

@@ -46,7 +44,7 @@ def make_app():
4644
app.static("/docs", str(HERE / "build"))
4745

4846
@app.route("/")
49-
async def forward_to_index(request):
47+
async def forward_to_index(_):
5048
return response.redirect("/docs/index.html")
5149

5250
configure(

docs/examples.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from __future__ import annotations
22

3+
from collections.abc import Iterator
34
from io import StringIO
45
from pathlib import Path
56
from traceback import format_exc
6-
from typing import Callable, Iterator
7+
from typing import Callable
78

89
import reactpy
910
from reactpy.types import ComponentType
1011

11-
1212
HERE = Path(__file__)
1313
SOURCE_DIR = HERE.parent / "source"
1414
CONF_FILE = SOURCE_DIR / "conf.py"
@@ -148,7 +148,6 @@ def __init__(self, max_lines: int = 10):
148148

149149
def set_callback(self, function: Callable[[str], None]) -> None:
150150
self._callback = function
151-
return None
152151

153152
def getvalue(self) -> str:
154153
return "".join(self._lines)

docs/source/_exts/async_doctest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from sphinx.ext.doctest import DocTestBuilder
77
from sphinx.ext.doctest import setup as doctest_setup
88

9-
109
test_template = """
1110
import asyncio as __test_template_asyncio
1211
@@ -41,10 +40,8 @@ def test_runner(self) -> DocTestRunner:
4140
@test_runner.setter
4241
def test_runner(self, value: DocTestRunner) -> None:
4342
self._test_runner = TestRunnerWrapper(value)
44-
return None
4543

4644

4745
def setup(app: Sphinx) -> None:
4846
doctest_setup(app)
4947
app.add_builder(AsyncDoctestBuilder, override=True)
50-
return None

docs/source/_exts/autogen_api_docs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from __future__ import annotations
22

33
import sys
4+
from collections.abc import Collection, Iterator
45
from pathlib import Path
5-
from typing import Collection, Iterator
66

77
from sphinx.application import Sphinx
88

9-
109
HERE = Path(__file__).parent
1110
SRC = HERE.parent.parent.parent / "src"
1211
PYTHON_PACKAGE = SRC / "reactpy"
@@ -83,7 +82,9 @@ def get_module_name(path: Path) -> str:
8382

8483
def get_section_symbol(path: Path) -> str:
8584
rel_path_parts = path.relative_to(PYTHON_PACKAGE).parts
86-
assert len(rel_path_parts) < len(SECTION_SYMBOLS), "package structure is too deep"
85+
if len(rel_path_parts) < len(SECTION_SYMBOLS):
86+
msg = "package structure is too deep"
87+
raise RuntimeError(msg)
8788
return SECTION_SYMBOLS[len(rel_path_parts)]
8889

8990

docs/source/_exts/build_custom_js.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from sphinx.application import Sphinx
55

6-
76
SOURCE_DIR = Path(__file__).parent.parent
87
CUSTOM_JS_DIR = SOURCE_DIR / "_custom_js"
98

docs/source/_exts/custom_autosectionlabel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from sphinx.util import logging
1818
from sphinx.util.nodes import clean_astext
1919

20-
2120
logger = logging.getLogger(__name__)
2221

2322

docs/source/_exts/reactpy_example.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ def run(self):
4141
ex_files = get_example_files_by_name(example_name)
4242
if not ex_files:
4343
src_file, line_num = self.get_source_info()
44-
raise ValueError(
45-
f"Missing example named {example_name!r} "
46-
f"referenced by document {src_file}:{line_num}"
47-
)
44+
msg = f"Missing example named {example_name!r} referenced by document {src_file}:{line_num}"
45+
raise ValueError(msg)
4846

4947
labeled_tab_items: list[tuple[str, Any]] = []
5048
if len(ex_files) == 1:
@@ -114,7 +112,8 @@ def _literal_include(path: Path, linenos: bool):
114112
".json": "json",
115113
}[path.suffix]
116114
except KeyError:
117-
raise ValueError(f"Unknown extension type {path.suffix!r}")
115+
msg = f"Unknown extension type {path.suffix!r}"
116+
raise ValueError(msg) from None
118117

119118
return _literal_include_template.format(
120119
name=str(path.relative_to(SOURCE_DIR)),

docs/source/_exts/reactpy_view.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from docs.examples import get_normalized_example_name
99

10-
1110
_REACTPY_EXAMPLE_HOST = os.environ.get("REACTPY_DOC_EXAMPLE_SERVER_HOST", "")
1211
_REACTPY_STATIC_HOST = os.environ.get("REACTPY_DOC_STATIC_SERVER_HOST", "/docs").rstrip(
1312
"/"

0 commit comments

Comments
 (0)