Skip to content

Commit 9369442

Browse files
committed
potentially working check workflows
1 parent 42f4ab3 commit 9369442

File tree

19 files changed

+1153
-765
lines changed

19 files changed

+1153
-765
lines changed

.github/workflows/check.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,32 @@ jobs:
1515
uses: ./.github/workflows/.hatch-run.yml
1616
with:
1717
job-name: "python-{0}"
18-
hatch-run: "test-py"
18+
run-cmd: "hatch test --cover"
1919
lint-py:
2020
uses: ./.github/workflows/.hatch-run.yml
2121
with:
2222
job-name: "python-{0}"
23-
hatch-run: "lint-py"
23+
run-cmd: "hatch run python:check"
2424
test-py-matrix:
2525
uses: ./.github/workflows/.hatch-run.yml
2626
with:
2727
job-name: "python-{0} {1}"
28-
hatch-run: "test-py --no-cov"
28+
run-cmd: "hatch test"
2929
runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]'
3030
python-version: '["3.9", "3.10", "3.11"]'
3131
test-docs:
3232
uses: ./.github/workflows/.hatch-run.yml
3333
with:
3434
job-name: "python-{0}"
35-
hatch-run: "test-docs"
36-
# as of Dec 2023 lxml does have wheels for 3.12
37-
# https://bugs.launchpad.net/lxml/+bug/2040440
35+
run-cmd: "hatch run docs:check"
3836
python-version: '["3.11"]'
3937
test-js:
4038
uses: ./.github/workflows/.hatch-run.yml
4139
with:
4240
job-name: "{1}"
43-
hatch-run: "test-js"
41+
run-cmd: "hatch run javascript:test"
4442
lint-js:
4543
uses: ./.github/workflows/.hatch-run.yml
4644
with:
4745
job-name: "{1}"
48-
hatch-run: "lint-js"
46+
run-cmd: "hatch run javascript:check"

LICENSE.md renamed to LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## The MIT License (MIT)
1+
The MIT License (MIT)
22

3-
#### Copyright (c) Reactive Python and affiliates.
3+
Copyright (c) Reactive Python and affiliates.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

docs/README.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
11
# ReactPy's Documentation
22

3-
We provide two main ways to run the docs. Both use
4-
[`nox`](https://pypi.org/project/nox/):
5-
6-
- `nox -s docs` - displays the docs and rebuilds when files are modified.
7-
- `nox -s docs-in-docker` - builds a docker image and runs the docs from there.
8-
9-
If any changes to the core of the documentation are made (i.e. to non-`*.rst` files),
10-
then you should run a manual test of the documentation using the `docs_in_docker`
11-
session.
12-
13-
If you wish to build and run the docs by hand you need to perform two commands, each
14-
being run from the root of the repository:
15-
16-
- `sphinx-build -b html docs/source docs/build`
17-
- `python scripts/run_docs.py`
18-
19-
The first command constructs the static HTML and any Javascript. The latter actually
20-
runs the web server that serves the content.
3+
...

docs/poetry.lock

Lines changed: 1087 additions & 685 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ readme = "README.md"
77

88
[tool.poetry.dependencies]
99
python = "^3.9"
10-
reactpy = { path = "../src/py/reactpy", extras = ["starlette", "sanic", "fastapi", "flask", "tornado", "testing"], develop = false }
1110
furo = "2022.04.07"
11+
reactpy = { path = "..", extras = ["all"], develop = false }
1212
sphinx = "*"
1313
sphinx-autodoc-typehints = "*"
1414
sphinx-copybutton = "*"

docs/source/_custom_js/package-lock.json

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/source/_exts/autogen_api_docs.py

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

99
HERE = Path(__file__).parent
1010
SRC = HERE.parent.parent.parent / "src"
11-
PYTHON_PACKAGE = SRC / "py" / "reactpy" / "reactpy"
11+
PYTHON_PACKAGE = SRC / "reactpy"
1212

1313
AUTO_DIR = HERE.parent / "_auto"
1414
AUTO_DIR.mkdir(exist_ok=True)

pyproject.toml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,29 +132,48 @@ cov = ["test-cov {args}", "cov-report"]
132132
[tool.hatch.envs.default.env-vars]
133133
REACTPY_DEBUG_MODE = "1"
134134

135+
#######################################
136+
# >>> Hatch Documentation Scripts <<< #
137+
#######################################
138+
[tool.hatch.envs.docs]
139+
template = "docs"
140+
dependencies = ["poetry"]
141+
detached = true
142+
143+
[tool.hatch.envs.docs.scripts]
144+
build = [
145+
"cd docs && poetry install",
146+
"cd docs && poetry run sphinx-build -a -T -W --keep-going -b doctest source build",
147+
]
148+
docker_build = [
149+
"hatch run docs:build",
150+
"cd docs && docker build . --file ./docs/Dockerfile --tag reactpy-docs:latest",
151+
]
152+
check = [
153+
"cd docs && poetry install",
154+
"cd docs && poetry run sphinx-build -a -T -W --keep-going -b doctest source build",
155+
"cd docs && docker build . --file docs/Dockerfile",
156+
]
157+
135158
################################
136159
# >>> Hatch Python Scripts <<< #
137160
################################
138161

139-
[tool.hatch.envs.lint]
162+
[tool.hatch.envs.python]
140163
extra-dependencies = [
141-
"black==24.1.1",
142-
"ruff==0.0.278",
143-
"flake8==7.0.0",
164+
"ruff",
144165
"toml",
145-
"flake8-pyproject",
146-
"mypy",
147-
"types-toml",
148166
"mypy==1.8",
167+
"types-toml",
149168
"types-click",
150169
"types-tornado",
151170
"types-flask",
152171
"types-requests",
153172
]
154173

155174
[tool.hatch.envs.python.scripts]
156-
# TODO: Replace mypy with pylint
157-
type_check = "mypy --strict src/reactpy"
175+
# TODO: Replace mypy with pyright
176+
check = ["mypy --strict src/reactpy", "hatch fmt src/reactpy --check"]
158177

159178
############################
160179
# >>> Hatch JS Scripts <<< #
@@ -236,7 +255,7 @@ omit = ["reactpy/__main__.py"]
236255
[tool.ruff]
237256
target-version = "py39"
238257
line-length = 88
239-
select = [
258+
lint.select = [
240259
"A",
241260
"ARG",
242261
"B",
@@ -250,7 +269,6 @@ select = [
250269
# "FBT",
251270
"I",
252271
"ICN",
253-
"ISC",
254272
"N",
255273
"PLC",
256274
"PLE",
@@ -265,7 +283,7 @@ select = [
265283
"W",
266284
"YTT",
267285
]
268-
ignore = [
286+
lint.ignore = [
269287
# TODO: turn this on later
270288
"N802",
271289
"N806", # allow TitleCase functions/variables
@@ -299,22 +317,22 @@ ignore = [
299317
"PLR0913",
300318
"PLR0915",
301319
]
302-
unfixable = [
320+
lint.unfixable = [
303321
# Don't touch unused imports
304322
"F401",
305323
]
306324

307-
[tool.ruff.isort]
325+
[tool.ruff.lint.isort]
308326
known-first-party = ["reactpy"]
309327

310-
[tool.ruff.flake8-tidy-imports]
328+
[tool.ruff.lint.flake8-tidy-imports]
311329
ban-relative-imports = "all"
312330

313331
[tool.flake8]
314332
select = ["RPY"] # only need to check with reactpy-flake8
315333
exclude = ["**/node_modules/*", ".eggs/*", ".tox/*", "**/venv/*"]
316334

317-
[tool.ruff.per-file-ignores]
335+
[tool.ruff.lint.per-file-ignores]
318336
# Tests can use magic values, assertions, and relative imports
319337
"**/tests/**/*" = ["PLR2004", "S101", "TID252"]
320338
"docs/**/*.py" = [

src/reactpy/_console/rewrite_camel_case_props.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import ast
44
import re
5-
import sys
65
from copy import copy
76
from keyword import kwlist
87
from pathlib import Path
@@ -23,9 +22,6 @@
2322
@click.argument("paths", nargs=-1, type=click.Path(exists=True))
2423
def rewrite_camel_case_props(paths: list[str]) -> None:
2524
"""Rewrite camelCase props to snake_case"""
26-
if sys.version_info < (3, 9): # nocov
27-
msg = "This command requires Python>=3.9"
28-
raise RuntimeError(msg)
2925

3026
for p in map(Path, paths):
3127
for f in [p] if p.is_file() else p.rglob("*.py"):

src/reactpy/_console/rewrite_keys.py

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

33
import ast
4-
import sys
54
from pathlib import Path
65

76
import click
@@ -45,9 +44,6 @@ def rewrite_keys(paths: list[str]) -> None:
4544
just above its changes. As such it requires manual intervention to put those
4645
comments back in their original location.
4746
"""
48-
if sys.version_info < (3, 9): # nocov
49-
msg = "This command requires Python>=3.9"
50-
raise RuntimeError(msg)
5147

5248
for p in map(Path, paths):
5349
for f in [p] if p.is_file() else p.rglob("*.py"):

src/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 # noqa: F811
16+
warn = _warn
1717

1818

1919
def _frame_depth_in_module() -> int:

src/reactpy/backend/tornado.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def _setup_single_view_dispatcher_route(
162162
]
163163

164164

165-
class IndexHandler(RequestHandler):
165+
class IndexHandler(RequestHandler): # type: ignore
166166
_index_html: str
167167

168168
def initialize(self, index_html: str) -> None:
@@ -172,7 +172,7 @@ async def get(self, _: str) -> None:
172172
self.finish(self._index_html)
173173

174174

175-
class ModelStreamHandler(WebSocketHandler):
175+
class ModelStreamHandler(WebSocketHandler): # type: ignore
176176
"""A web-socket handler that serves up a new model stream to each new client"""
177177

178178
_dispatch_future: Future[None]
@@ -202,7 +202,7 @@ async def recv() -> Any:
202202
value=Connection(
203203
scope=_FAKE_WSGI_CONTAINER.environ(self.request),
204204
location=Location(
205-
pathname=f"/{path[len(self._url_prefix):]}",
205+
pathname=f"/{path[len(self._url_prefix) :]}",
206206
search=(
207207
f"?{self.request.query}"
208208
if self.request.query

src/reactpy/core/component.py

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

99

1010
def component(
11-
function: Callable[..., ComponentType | VdomDict | str | None]
11+
function: Callable[..., ComponentType | VdomDict | str | None],
1212
) -> Callable[..., Component]:
1313
"""A decorator for defining a new component.
1414

src/reactpy/core/events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def event(
4848
.. code-block:: python
4949
5050
@event(stop_propagation=True, prevent_default=True)
51-
def my_callback(*data):
52-
...
51+
def my_callback(*data): ...
52+
5353
5454
element = reactpy.html.button({"onClick": my_callback})
5555

src/reactpy/core/vdom.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def separate_attributes_and_children(
282282

283283

284284
def separate_attributes_and_event_handlers(
285-
attributes: Mapping[str, Any]
285+
attributes: Mapping[str, Any],
286286
) -> tuple[dict[str, Any], EventHandlerDict]:
287287
separated_attributes = {}
288288
separated_event_handlers: dict[str, EventHandlerType] = {}
@@ -295,8 +295,7 @@ def separate_attributes_and_event_handlers(
295295
elif (
296296
# isinstance check on protocols is slow - use function attr pre-check as a
297297
# quick filter before actually performing slow EventHandlerType type check
298-
hasattr(v, "function")
299-
and isinstance(v, EventHandlerType)
298+
hasattr(v, "function") and isinstance(v, EventHandlerType)
300299
):
301300
handler = v
302301
else:

src/reactpy/html.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ def _script(
458458
.. code-block:: python
459459
460460
import json
461+
461462
my_script = html.script(f"console.log({json.dumps(user_bio)});")
462463
463464
This would prevent the injection of Javascript code by escaping the ``user_bio``

src/reactpy/testing/backend.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,22 @@ def _hotswap(update_on_change: bool = False) -> tuple[_MountFunc, ComponentConst
174174
show, root = reactpy.hotswap()
175175
PerClientStateServer(root).run_in_thread("localhost", 8765)
176176
177+
177178
@reactpy.component
178179
def DivOne(self):
179180
return {"tagName": "div", "children": [1]}
180181
182+
181183
show(DivOne)
182184
183185
# displaying the output now will show DivOne
184186
187+
185188
@reactpy.component
186189
def DivTwo(self):
187190
return {"tagName": "div", "children": [2]}
188191
192+
189193
show(DivTwo)
190194
191195
# displaying the output now will show DivTwo

tests/test_console/test_rewrite_camel_case_props.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from pathlib import Path
32
from textwrap import dedent
43

@@ -10,9 +9,6 @@
109
rewrite_camel_case_props,
1110
)
1211

13-
if sys.version_info < (3, 9):
14-
pytestmark = pytest.mark.skip(reason="ast.unparse is Python>=3.9")
15-
1612

1713
def test_rewrite_camel_case_props_declarations(tmp_path):
1814
runner = CliRunner()

0 commit comments

Comments
 (0)