-
-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathpyproject.toml
More file actions
344 lines (314 loc) · 9.23 KB
/
pyproject.toml
File metadata and controls
344 lines (314 loc) · 9.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling", "hatch-build-scripts", "hatch"]
##############################
# >>> Hatch Build Config <<< #
##############################
[project]
name = "reactpy"
description = "It's React, but in Python."
readme = "README.md"
keywords = [
"react",
"reactjs",
"reactpy",
"components",
"asgi",
"wsgi",
"website",
"interactive",
"reactive",
"javascript",
"server",
]
license = "MIT"
authors = [
{ name = "Mark Bakhit", email = "archiethemonger@gmail.com" },
{ name = "Ryan Morshead", email = "ryan.morshead@gmail.com" },
]
requires-python = ">=3.11"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = ["fastjsonschema>=2.14.5", "requests>=2", "lxml>=4", "anyio>=3"]
dynamic = ["version"]
urls.Changelog = "https://reactpy.dev/docs/about/changelog.html"
urls.Documentation = "https://reactpy.dev/"
urls.Source = "https://github.com/reactive-python/reactpy"
[project.optional-dependencies]
all = ["reactpy[asgi,jinja,testing]"]
asgi = ["asgiref", "asgi-tools", "servestatic", "orjson"]
jinja = ["jinja2-simple-tags", "jinja2>=3"]
testing = ["playwright", "uvicorn[standard]"]
[tool.hatch.version]
path = "src/reactpy/__init__.py"
[tool.hatch.build.targets.sdist]
include = ["/src"]
artifacts = ["/src/reactpy/static/"]
[tool.hatch.build.targets.wheel]
artifacts = ["/src/reactpy/static/"]
[tool.hatch.metadata]
license-files = { paths = ["LICENSE"] }
[tool.hatch.envs.default]
installer = "uv"
[project.scripts]
reactpy = "reactpy._console.cli:entry_point"
[[tool.hatch.build.hooks.build-scripts.scripts]]
commands = []
artifacts = []
#############################
# >>> Hatch Test Runner <<< #
#############################
[tool.hatch.envs.hatch-test.scripts]
run = [
'hatch --env default run "src/build_scripts/install_playwright.py"',
"hatch --env default run javascript:build --dev",
"hatch --env default build -t wheel",
"pytest{env:HATCH_TEST_ARGS:} {args} --max-worker-restart 10",
]
run-cov = [
'hatch --env default run "src/build_scripts/install_playwright.py"',
"hatch --env default run javascript:build --dev",
"hatch --env default build -t wheel",
'hatch --env default run "src/build_scripts/delete_old_coverage.py"',
"coverage run -m pytest{env:HATCH_TEST_ARGS:} {args} --max-worker-restart 10",
]
cov-combine = "coverage combine"
cov-report = "coverage report"
[tool.hatch.envs.hatch-test]
extra-dependencies = [
"pytest-sugar",
"pytest-asyncio",
"pytest-timeout",
"responses",
"exceptiongroup",
"jsonpointer",
"starlette",
]
features = ["all"]
[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.11", "3.12", "3.13", "3.14"]
[tool.pytest.ini_options]
addopts = ["--strict-config", "--strict-markers"]
filterwarnings = """
ignore::DeprecationWarning:uvicorn.*
ignore::DeprecationWarning:websockets.*
ignore::UserWarning:tests.test_core.test_vdom
ignore::UserWarning:tests.test_pyscript.test_components
ignore::UserWarning:tests.test_utils
"""
testpaths = "tests"
xfail_strict = true
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
asyncio_default_test_loop_scope = "session"
log_cli_level = "INFO"
timeout = 120
#######################################
# >>> Hatch Documentation Scripts <<< #
#######################################
[tool.hatch.envs.docs]
template = "docs"
dependencies = ["poetry"]
detached = true
[tool.hatch.envs.docs.scripts]
build = [
"cd docs && poetry install",
"cd docs && poetry run sphinx-build -a -T -W --keep-going -b doctest source build",
]
docker_build = [
"hatch run docs:build",
"docker build . --file ./docs/Dockerfile --tag reactpy-docs:latest",
]
docker_serve = [
"hatch run docs:docker_build",
"docker run --rm -p 5000:5000 reactpy-docs:latest",
]
check = [
"cd docs && poetry install",
"cd docs && poetry run sphinx-build -a -T -W --keep-going -b doctest source build",
"docker build . --file ./docs/Dockerfile",
]
serve = [
"cd docs && poetry install",
"cd docs && poetry run python main.py --watch=../src/ --ignore=**/_auto/* --ignore=**/custom.js --ignore=**/node_modules/* --ignore=**/package-lock.json -a -E -b html source build",
]
################################
# >>> Hatch Python Scripts <<< #
################################
[tool.hatch.envs.python]
extra-dependencies = [
"reactpy[all]",
"pyright",
"types-toml",
"types-click",
"types-requests",
"types-lxml",
"jsonpointer",
"pytest",
]
[tool.hatch.envs.python.scripts]
type_check = ["pyright src/reactpy"]
############################
# >>> Hatch JS Scripts <<< #
############################
[tool.hatch.envs.javascript]
detached = true
[tool.hatch.envs.javascript.scripts]
check = [
'hatch run javascript:build',
'bun run --cwd "src/js" lint',
'bun run --cwd "src/js/packages/event-to-object" checkTypes',
'bun run --cwd "src/js/packages/@reactpy/client" checkTypes',
'bun run --cwd "src/js/packages/@reactpy/app" checkTypes',
]
fix = ['bun install --cwd "src/js"', 'bun run --cwd "src/js" format']
test = ['hatch run javascript:build_event_to_object --dev', 'bun test']
build = [
'hatch run "src/build_scripts/clean_js_dir.py"',
'bun install --cwd "src/js"',
'hatch run javascript:build_event_to_object {args}',
'hatch run javascript:build_client {args}',
'hatch run javascript:build_app {args}',
'hatch --env default run "src/build_scripts/copy_dir.py" "src/js/node_modules/@pyscript/core/dist" "src/reactpy/static/pyscript"',
'hatch --env default run "src/build_scripts/copy_dir.py" "src/js/node_modules/morphdom/dist" "src/reactpy/static/morphdom"',
]
build_event_to_object = [
'hatch run "src/build_scripts/build_js_event_to_object.py" {args}',
]
build_client = ['hatch run "src/build_scripts/build_js_client.py" {args}']
build_app = ['hatch run "src/build_scripts/build_js_app.py" {args}']
publish_event_to_object = [
'hatch run javascript:build_event_to_object',
# FIXME: This is a temporary workaround. We are using `bun pm pack`->`npm publish` to fix missing "Trusted Publishing" support in `bun publish`
# See the following ticket https://github.com/oven-sh/bun/issues/15601
'cd "src/js/packages/event-to-object" && bun pm pack --filename "packages/event-to-object/dist.tgz" && bunx npm@11.8.0 publish dist.tgz --provenance --access public',
]
publish_client = [
'hatch run javascript:build_client',
# FIXME: This is a temporary workaround. We are using `bun pm pack`->`npm publish` to fix missing "Trusted Publishing" support in `bun publish`
# See the following ticket https://github.com/oven-sh/bun/issues/15601
'cd "src/js/packages/@reactpy/client" && bun pm pack --filename "packages/@reactpy/client/dist.tgz" && bunx npm@11.8.0 publish dist.tgz --provenance --access public',
]
#########################
# >>> Generic Tools <<< #
#########################
[tool.pyright]
reportIncompatibleVariableOverride = false
[tool.coverage.run]
source_pkgs = ["reactpy"]
branch = false
parallel = false
omit = [
"src/reactpy/__init__.py",
"src/reactpy/_console/*",
"src/reactpy/__main__.py",
"src/reactpy/executors/pyscript/layout_handler.py",
"src/reactpy/executors/pyscript/component_template.py",
]
[tool.coverage.report]
fail_under = 100
show_missing = true
skip_covered = true
sort = "Name"
exclude_also = [
"no ?cov",
'\.\.\.',
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
[tool.ruff]
line-length = 88
lint.select = [
"A",
"ARG",
"B",
"C",
"DTZ",
"E",
# error message linting is overkill
# "EM",
"F",
# TODO: turn this on later
# "FBT",
"I",
"ICN",
"N",
"PLC",
"PLE",
"PLR",
"PLW",
"Q",
"RUF",
"S",
"T",
"TID",
"UP",
"W",
"YTT",
]
lint.ignore = [
# TODO: turn this on later
"N802",
"N806", # allow TitleCase functions/variables
# We're not any cryptography
"S311",
# For loop variable re-assignment seems like an uncommon mistake
"PLW2901",
# Let Black deal with line-length
"E501",
# Allow args/attrs to shadow built-ins
"A002",
"A003",
# Allow unused args (useful for documenting what the parameter is for later)
"ARG001",
"ARG002",
"ARG005",
# Allow non-abstract empty methods in abstract base classes
"B027",
# Allow boolean positional values in function calls, like `dict.get(... True)`
"FBT003",
# If we're making an explicit comparison to a falsy value it was probably intentional
"PLC1901",
# Ignore checks for possible passwords
"S105",
"S106",
"S107",
# Ignore complexity
"C901",
"PLR0911",
"PLR0912",
"PLR0913",
"PLR0915",
# Allow imports anywhere
"PLC0415",
]
lint.unfixable = [
# Don't touch unused imports
"F401",
]
[tool.ruff.lint.isort]
known-first-party = ["reactpy"]
known-third-party = ["js"]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"**/tests/**/*" = ["PLR2004", "S101", "TID252"]
"docs/**/*.py" = [
# Examples require some extra setup before import
"E402",
# Allow exec
"S102",
# Allow print
"T201",
]
"scripts/**/*.py" = [
# Allow print
"T201",
]