Skip to content

Commit 3f84313

Browse files
committed
more fixes
1 parent e23fe71 commit 3f84313

File tree

6 files changed

+50
-29
lines changed

6 files changed

+50
-29
lines changed

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ description = "Scripts for managing the ReactPy respository"
1111
detached = true
1212
dependencies = [
1313
"invoke",
14+
# lint
1415
"black",
1516
"ruff",
1617
"toml",
18+
"flake8",
19+
"flake8-pyproject",
20+
"reactpy-flake8 >=0.7",
21+
# publish
1722
"semver >=2, <3",
23+
"twine",
1824
]
1925

2026
[tool.hatch.envs.default.scripts]
@@ -33,6 +39,12 @@ test-docs = "invoke test-docs"
3339
target-version = ["py39"]
3440
line-length = 88
3541

42+
# --- Flake8 ----------------------------------------------------------------------------
43+
44+
[tool.flake8]
45+
select = ["RPY"] # only need to check with reactpy-flake8
46+
exclude = ["**/node_modules/*", ".eggs/*", ".tox/*", "**/venv/*"]
47+
3648
# --- Ruff -----------------------------------------------------------------------------
3749

3850
[tool.ruff]

requirements/check-types.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

requirements/make-release.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/py/reactpy/pyproject.toml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,21 @@ dependencies = [
9393
]
9494
[tool.hatch.envs.default.scripts]
9595
test = "playwright install && pytest {args:tests}"
96-
test-cov = "coverage run -m pytest {args:tests}"
96+
test-cov = "playwright install && coverage run -m pytest {args:tests}"
9797
cov-report = [
98-
"- coverage combine",
98+
# "- coverage combine",
9999
"coverage report",
100100
]
101101
cov = [
102102
"test-cov",
103103
"cov-report",
104104
]
105105

106+
[tool.hatch.envs.default.env-vars]
107+
REACTPY_DEBUG_MODE="1"
108+
106109
[tool.hatch.envs.lint]
107-
detached = true
110+
features = ["all"]
108111
dependencies = [
109112
"mypy>=1.0.0",
110113
"types-click",
@@ -149,25 +152,21 @@ warn_unused_ignores = true
149152
# --- Coverage -------------------------------------------------------------------------
150153

151154
[tool.coverage.run]
152-
source_pkgs = ["reactpy", "tests"]
153-
branch = true
154-
parallel = true
155+
source_pkgs = ["reactpy"]
156+
branch = false
157+
parallel = false
155158
omit = [
156159
"reactpy/__init__.py",
157160
]
158161

159-
[tool.coverage.paths]
160-
reactpy = ["reactpy", "*/reactpy/reactpy"]
161-
tests = ["tests", "*/reactpy/tests"]
162-
163162
[tool.coverage.report]
164163
fail_under = 100
165164
show_missing = true
166165
skip_covered = true
167166
sort = "Name"
168167
exclude_lines = [
169-
"no cov",
170-
'\.\.\.\$',
168+
"no ?cov",
169+
'\.\.\.',
171170
"if __name__ == .__main__.:",
172171
"if TYPE_CHECKING:",
173172
]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ def create_development_app() -> Any:
2727
return _default_implementation().create_development_app()
2828

2929

30-
def Options(*args: Any, **kwargs: Any) -> NoReturn:
30+
def Options(*args: Any, **kwargs: Any) -> NoReturn: # pragma: no cover
3131
"""Create configuration options"""
3232
msg = "Default implementation has no options."
33-
raise ValueError(msg) # pragma: no cover
33+
raise ValueError(msg)
3434

3535

3636
async def serve_development_app(

tasks.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import os
66
import re
77
import sys
8-
import toml
98
from dataclasses import dataclass
109
from pathlib import Path
1110
from shutil import rmtree
1211
from typing import TYPE_CHECKING, Any, Callable
1312

1413
import semver
14+
import toml
1515
from invoke import task
1616
from invoke.context import Context
1717
from invoke.exceptions import Exit
@@ -69,28 +69,45 @@ def __call__(
6969
@task
7070
def env(context: Context):
7171
"""Install development environment"""
72-
in_py(context, "pip install -e .", hide="out")
73-
in_js(context, "npm ci", hide="out")
72+
env_py(context)
73+
env_js(context)
74+
75+
76+
@task
77+
def env_py(context: Context):
78+
"""Install Python development environment"""
7479
for py_proj in PY_PROJECTS:
7580
py_proj_toml = toml.load(py_proj / "pyproject.toml")
7681
hatch_default_env = py_proj_toml["tool"]["hatch"]["envs"].get("default", {})
82+
hatch_default_features = hatch_default_env.get("features", [])
7783
hatch_default_deps = hatch_default_env.get("dependencies", [])
84+
with context.cd(py_proj):
85+
context.run(f"pip install '.[{','.join(hatch_default_features)}]'")
7886
context.run(f"pip install {' '.join(map(repr, hatch_default_deps))}")
7987

8088

89+
@task
90+
def env_js(context: Context):
91+
"""Install JS development environment"""
92+
in_js(context, "npm ci", hide="out")
93+
94+
8195
@task
8296
def lint_py(context: Context, fix: bool = False):
8397
"""Run linters and type checkers"""
8498
if fix:
85-
context.run("black .")
8699
context.run("ruff --fix .")
87100
else:
88101
context.run("ruff .")
89102
context.run("black --check --diff .")
90-
in_py(context, "hatch run lint:all")
103+
in_py(
104+
context,
105+
f"flake8 --toml-config {ROOT / 'pyproject.toml'} .",
106+
"hatch run lint:all",
107+
)
91108

92109

93-
@task
110+
@task(pre=[env_js])
94111
def lint_js(context: Context, fix: bool = False):
95112
"""Run linters and type checkers"""
96113
if fix:
@@ -106,13 +123,13 @@ def test_py(context: Context, no_cov: bool = False):
106123
in_py(context, f"hatch run {'test' if no_cov else 'cov'}")
107124

108125

109-
@task
126+
@task(pre=[env_js])
110127
def test_js(context: Context):
111128
"""Run test suites"""
112129
in_js(context, "npm run check:tests")
113130

114131

115-
@task
132+
@task(pre=[env_py])
116133
def test_docs(context: Context):
117134
raise Exit("Not implemented")
118135

0 commit comments

Comments
 (0)