Skip to content

Commit 5a370f0

Browse files
committed
chore: add development tooling (ruff, mypy, pre-commit)
1 parent 13f2184 commit 5a370f0

1 file changed

Lines changed: 60 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ Issues = "https://github.com/ServerlessLLM/pylet/issues"
4646
dev = [
4747
"pytest>=7.0.0",
4848
"pytest-asyncio>=0.21.0",
49+
"ruff>=0.8.0",
50+
"mypy>=1.14.0",
51+
"pre-commit>=4.0.0",
4952
]
5053

5154
[project.scripts]
@@ -60,4 +63,60 @@ asyncio_default_fixture_loop_scope = "function"
6063
testpaths = ["tests"]
6164
python_files = ["test_*.py"]
6265
python_classes = ["Test*"]
63-
python_functions = ["test_*"]
66+
python_functions = ["test_*"]
67+
68+
[tool.ruff]
69+
target-version = "py39"
70+
line-length = 100
71+
src = ["pylet", "tests"]
72+
73+
[tool.ruff.lint]
74+
select = [
75+
"E", # pycodestyle errors
76+
"W", # pycodestyle warnings
77+
"F", # pyflakes
78+
"I", # isort
79+
"UP", # pyupgrade
80+
"B", # flake8-bugbear
81+
"SIM", # flake8-simplify
82+
"RUF", # ruff-specific rules
83+
]
84+
ignore = [
85+
"E501", # line too long (handled by formatter)
86+
"B008", # do not perform function calls in argument defaults (needed for FastAPI Depends)
87+
"B904", # raise from err (HTTP exceptions don't need chains)
88+
"RUF022", # __all__ not sorted (intentionally grouped by category)
89+
"SIM102", # nested if statements (sometimes clearer)
90+
"SIM105", # use contextlib.suppress (style preference)
91+
"SIM115", # use context manager for open (not always possible)
92+
"SIM117", # use single with statement (nested sometimes clearer)
93+
"UP035", # typing.X deprecated (need Optional, Union for Python 3.9 compat)
94+
]
95+
96+
[tool.ruff.lint.isort]
97+
known-first-party = ["pylet"]
98+
99+
[tool.mypy]
100+
python_version = "3.9"
101+
warn_return_any = false
102+
warn_unused_ignores = true
103+
disallow_untyped_defs = false
104+
check_untyped_defs = true
105+
ignore_missing_imports = true
106+
strict_optional = true
107+
files = ["pylet"]
108+
exclude = ["tests"]
109+
110+
# Per-module overrides for stricter checking on core modules
111+
[[tool.mypy.overrides]]
112+
module = "pylet.schemas"
113+
disallow_untyped_defs = true
114+
115+
[[tool.mypy.overrides]]
116+
module = "pylet.errors"
117+
disallow_untyped_defs = true
118+
119+
# db.py uses Optional[Connection] but methods assume connect() was called
120+
[[tool.mypy.overrides]]
121+
module = "pylet.db"
122+
disable_error_code = ["union-attr"]

0 commit comments

Comments
 (0)