Skip to content

Commit 5eb2c87

Browse files
authored
feat(py): move lint checks to scripts/lint and add config for pyrefly (#288)
1 parent af5827b commit 5eb2c87

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

python/pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dev = [
3737
"tox-uv>=1.25.0",
3838
"nox>=2025.2.9",
3939
"nox-uv>=0.2.1",
40+
"pyrefly>=0.16.1",
4041
]
4142
lint = ["mypy>=1.14.1", "ruff>=0.9.2"]
4243

@@ -152,3 +153,33 @@ disallow_incomplete_defs = true
152153
disallow_untyped_defs = true
153154
strict = true
154155
warn_unused_configs = true
156+
157+
[tool.pyrefly]
158+
project_excludes = [
159+
"**/.[!/.]*", # Hidden files and folders.
160+
"**/*venv/**", # venv directories.
161+
".mypy_cache",
162+
".pytest_cache",
163+
".ruff_cache",
164+
".tox",
165+
"__pypackages__",
166+
"_build",
167+
"build",
168+
"dist",
169+
"node_modules",
170+
]
171+
project_includes = ["dotpromptz", "handlebarrz", "tests"]
172+
python_version = "3.10" # Matches ruff.target-version
173+
search_path = ["."]
174+
175+
# How to handle untyped function definitions.
176+
# "error": Emit an error (similar to mypy's disallow_untyped_defs = true).
177+
# "check": Type check the body as if it were annotated.
178+
# "skip": Skip checking the body (default).
179+
untyped_def_behavior = "error"
180+
181+
# By default, all errors are enabled if the [tool.pyrefly.errors] table is empty or not present.
182+
# For maximum strictness similar to 'mypy --strict', we rely on this default behavior.
183+
# If specific errors need to be disabled later, they can be added here:
184+
# [tool.pyrefly.errors]
185+
# example-error-code = false

python/uv.lock

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/lint

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ if ((EUID == 0)); then
2323
fi
2424

2525
TOP_DIR=$(git rev-parse --show-toplevel)
26+
PY_DIR="${TOP_DIR}/python"
27+
28+
uv run --directory "${PY_DIR}" ruff check --select I --fix --preview --unsafe-fixes .
29+
uv run --directory "${PY_DIR}" mypy .
30+
31+
# Add pylyzer, ty, and pyrefly
32+
#uv run --directory "${PY_DIR}" pylyzer --check .
33+
#uv run --directory "${PY_DIR}" ty check
34+
uv run --directory "${PY_DIR}" pyrefly check

scripts/run_python_checks

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ PYTHON_VERSIONS=(
3636
)
3737

3838
echo "=== Running Python lint ==="
39-
uv run --directory "${PY_DIR}" ruff check --select I --fix --preview --unsafe-fixes .
40-
uv run --directory "${PY_DIR}" mypy .
39+
"${TOP_DIR}/scripts/lint"
4140

4241
echo "=== Running Python tests ==="
4342
echo "Project root: ${TOP_DIR}"

0 commit comments

Comments
 (0)