Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ reflex.db
.env.*
node_modules
package-lock.json
*.pyi
*.pyi
.pre-commit-config.yaml
48 changes: 0 additions & 48 deletions .pre-commit-config.yaml

This file was deleted.

55 changes: 53 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ artifacts = ["*.pyi"]

[tool.hatch.build.hooks.custom]
path = "scripts/hatch_build.py"
dependencies = ["plotly", "ruff"]
dependencies = ["plotly", "ruff", "pre_commit", "toml"]
require-runtime-dependencies = true

[tool.pyright]
Expand Down Expand Up @@ -149,7 +149,7 @@ dev = [
"pillow >=11",
"playwright >=1.51",
"plotly >=6.0",
"pre-commit >=4.2",
"pre-commit ==4.2.0",
"psycopg[binary] >=3.2",
"pyright >=1.1.400",
"pytest >=8.3",
Expand All @@ -165,6 +165,7 @@ dev = [
"ruff >=0.11",
"selenium >=4.31",
"starlette-admin >=0.14",
"toml >=0.10.2",
"uvicorn >=0.34.0",
]

Expand Down Expand Up @@ -206,3 +207,53 @@ exclude_also = [

[tool.coverage.html]
directory = "coverage_html_report"

[tool.pre-commit]
fail_fast = true

[[tool.pre-commit.repos]]
repo = "https://github.com/astral-sh/ruff-pre-commit"
rev = "v0.11.8"
hooks = [
{ id = "ruff-format", args = [
"reflex",
"tests",
] },
{ id = "ruff", args = [
"--fix",
"--exit-non-zero-on-fix",
], exclude = "^integration/benchmarks/" },
]

[[tool.pre-commit.repos]]
repo = "https://github.com/codespell-project/codespell"
rev = "v2.4.1"
hooks = [
{ id = "codespell", args = [
"reflex",
], additional_dependencies = [
"tomli",
] },
]

# Run pyi check before pyright because pyright can fail if pyi files are wrong.
[[tool.pre-commit.repos]]
repo = "local"
hooks = [
{ id = "update-pyi-files", name = "update-pyi-files", always_run = true, language = "system", require_serial = true, description = "Update pyi files as needed", entry = "python3 scripts/make_pyi.py" },
]

[[tool.pre-commit.repos]]
repo = "https://github.com/RobertCraigie/pyright-python"
rev = "v1.1.400"
hooks = [{ id = "pyright", args = ["reflex", "tests"], language = "system" }]

[[tool.pre-commit.repos]]
repo = "https://github.com/terrencepreilly/darglint"
rev = "v1.8.1"
hooks = [{ id = "darglint", exclude = "^reflex/reflex.py" }]

[[tool.pre-commit.repos]]
repo = "https://github.com/pre-commit/mirrors-prettier"
rev = "f62a70a3a7114896b062de517d72829ea1c884b6"
hooks = [{ id = "prettier", require_serial = true }]
17 changes: 17 additions & 0 deletions scripts/hatch_build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Custom build hook for Hatch."""

import importlib.util
import pathlib
import subprocess
import sys
Expand Down Expand Up @@ -37,6 +38,22 @@ def finalize(
if self.marker().exists():
return

if importlib.util.find_spec("pre_commit") and importlib.util.find_spec("toml"):
import json

import toml
import yaml

reflex_dir = pathlib.Path(__file__).parent.parent
pre_commit_config = json.loads(
json.dumps(
toml.load(reflex_dir / "pyproject.toml")["tool"]["pre-commit"]
)
)
(reflex_dir / ".pre-commit-config.yaml").write_text(
yaml.dump(pre_commit_config), encoding="utf-8"
)

if not (pathlib.Path(self.root) / "scripts").exists():
return

Expand Down
13 changes: 12 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.