Skip to content

Commit dacbb75

Browse files
authored
chore: setup linters, pre-commit and CI (#1)
1 parent 7b7c204 commit dacbb75

File tree

17 files changed

+797
-165
lines changed

17 files changed

+797
-165
lines changed

.github/workflows/ci.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v2
17+
with:
18+
version: ${{ vars.UV_VERSION || '0.6.9' }}
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.11'
24+
25+
- name: Cache pre-commit
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/.cache/pre-commit
29+
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
30+
31+
- name: Run pre-commit checks
32+
run: |
33+
uv run pre-commit run --all-files --show-diff-on-failure --color always
34+
35+
- name: Validate package build
36+
run: |
37+
uv build --out-dir dist

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ wheels/
1111
.aider*
1212
.env
1313

14-
.idea/
14+
.idea/

.pre-commit-config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-merge-conflict
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-added-large-files
10+
- id: check-toml
11+
- id: check-json
12+
- id: check-yaml
13+
14+
- repo: local
15+
hooks:
16+
- id: format
17+
name: format
18+
types_or: [python, jupyter]
19+
entry: uv run ruff format
20+
language: system
21+
always_run: false
22+
23+
- repo: local
24+
hooks:
25+
- id: lint
26+
name: lint
27+
types_or: [python, jupyter]
28+
entry: uv run ruff check --fix
29+
language: system
30+
always_run: false
31+
32+
- repo: local
33+
hooks:
34+
- id: check-types
35+
name: check types
36+
types_or: [python, jupyter]
37+
entry: uv run mypy .
38+
language: system
39+
always_run: false
40+
pass_filenames: false

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ The `template_config.py` file should define a `TemplateConfig` class that inheri
4242

4343
```python
4444
from create_ragbits_app.template_config_base import (
45-
BaseTemplateConfig,
46-
TextQuestion,
47-
ListQuestion,
45+
BaseTemplateConfig,
46+
TextQuestion,
47+
ListQuestion,
4848
ConfirmQuestion
4949
)
5050

5151
class TemplateConfig(TemplateConfig):
5252
name: str = "My Template Name"
5353
description: str = "Description of the template"
54-
54+
5555
questions: List = [
5656
TextQuestion(
5757
name="variable_name",

pyproject.toml

Lines changed: 174 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "create-ragbits-app"
33
version = "0.0.4"
4-
description = "Add your description here"
4+
description = "Set up a modern LLM app by running one command"
55
readme = "README.md"
66
requires-python = ">=3.11"
77
dependencies = [
@@ -13,10 +13,19 @@ dependencies = [
1313
"twine>=6.1.0",
1414
]
1515

16-
1716
[project.scripts]
1817
create-ragbits-app = "create_ragbits_app.main:entrypoint"
1918

19+
[tool.uv]
20+
dev-dependencies = [
21+
"pre-commit==4.2.0",
22+
"pytest==8.3.5",
23+
"pytest-cov==5.0.0",
24+
"pytest-asyncio==0.24.0",
25+
"ruff==0.11.5",
26+
"mypy==1.15.0",
27+
]
28+
2029
[build-system]
2130
requires = ["hatchling"]
2231
build-backend = "hatchling.build"
@@ -28,4 +37,166 @@ allow-direct-references = true
2837
packages = ["src/create_ragbits_app"]
2938

3039
[tool.hatch.build]
31-
include = ['src/**/*', 'templates/**/*']
40+
include = ['src/**/*', 'templates/**/*']
41+
42+
[tool.pytest]
43+
norecursedirs = [
44+
'.git',
45+
'.tox',
46+
'.env',
47+
'dist',
48+
'build',
49+
'migrations',
50+
'docker',
51+
'config',
52+
'notebooks',
53+
'research',
54+
]
55+
python_files = ['test_*.py']
56+
addopts = [
57+
'-ra',
58+
'--showlocals',
59+
'--strict-markers',
60+
'--ignore=docs/conf.py',
61+
'--ignore=setup.py',
62+
'--ignore=ci',
63+
'--ignore=.eggs',
64+
'--doctest-modules',
65+
'--doctest-glob=\*.rst',
66+
'--tb=short',
67+
]
68+
69+
[tool.pytest.ini_options]
70+
addopts = "--import-mode=importlib"
71+
asyncio_mode = "auto"
72+
asyncio_default_fixture_loop_scope = "function"
73+
74+
[tool.mypy]
75+
warn_unused_configs = true
76+
ignore_missing_imports = true
77+
warn_unused_ignores = false
78+
show_error_codes = true
79+
check_untyped_defs = true
80+
no_implicit_optional = true
81+
explicit_package_bases = true
82+
mypy_path = ["src"]
83+
exclude = ["src/create_ragbits_app/templates/rag/src/{{pkg_name}}/__init__.py"]
84+
85+
[[tool.mypy.overrides]]
86+
module = "create_ragbits_app.*"
87+
ignore_missing_imports = false
88+
disallow_untyped_defs = true
89+
90+
[tool.ruff]
91+
exclude = [".venv"]
92+
extend-include = ["*.ipynb"]
93+
line-length = 120
94+
95+
[tool.ruff.lint]
96+
preview = true
97+
explicit-preview-rules = true
98+
select = [
99+
# Default rules
100+
"E", # pycodestyle errors
101+
"F", # Pyflakes
102+
"C4", # flake8-comprehensions
103+
"C90", # mccabe complex structure
104+
"D", # pydocstyle
105+
"I", # isort
106+
"PT", # flake8-pytest-style
107+
"PL", # Pylint
108+
"SIM", # flake8-simplify
109+
"UP", # pyupgrade
110+
"W", # pycodestyle warnings
111+
"S", # flake8-bandit
112+
"ANN", # flake8-annotations
113+
"B", # flake8-bugbear
114+
"NPY", # NumPy-specific rules
115+
]
116+
extend-select = [
117+
"RUF022", # unsorted-dunder-all
118+
"PLR6301", # no-self-use
119+
]
120+
ignore = [
121+
"B024",
122+
"B028", # no-explicit-stacklevel, TODO confirm this
123+
"C901", # complex-structure, TODO confirm this
124+
"D100",
125+
"D104",
126+
"D105",
127+
"D107",
128+
"D415",
129+
"D200",
130+
"D205",
131+
"D212",
132+
"ANN002",
133+
"ANN003",
134+
"ANN101",
135+
"ANN102",
136+
"ANN204",
137+
"PLR0913",
138+
]
139+
140+
[tool.ruff.lint.pydocstyle]
141+
convention = "google"
142+
143+
[tool.ruff.lint.per-file-ignores]
144+
"*.ipynb" = [
145+
"PLR2004",
146+
"W293",
147+
"D101", # D*** - we should not require docs in every Jupyter notebook
148+
"D102",
149+
"D103",
150+
"D107"
151+
]
152+
"**/tests/**/*.py" = [
153+
"S101", # asserts allowed in tests...
154+
"ARG", # Unused function args
155+
"D101", # Missing docstring in public class
156+
"D102", # Missing docstring in public method
157+
"D103", # Missing docstring in public function
158+
"PT011", # we prefer assert at the end of the test instead of using "match" parameter in pytest.raises
159+
"ANN201", # Missing return type annotation
160+
"PLR2004", # Magic numbers are ok in tests
161+
]
162+
[tool.ruff.format]
163+
docstring-code-format = true
164+
docstring-code-line-length = 120
165+
166+
[tool.ruff.lint.isort]
167+
known-first-party = ["create_ragbits_app"]
168+
known-third-party = [
169+
"IPython",
170+
"PIL",
171+
"cv2",
172+
"dotenv",
173+
"editdistance",
174+
"fastapi",
175+
"fire",
176+
"hydra",
177+
"joblib",
178+
"loguru",
179+
"luigi",
180+
"matplotlib",
181+
"neptune",
182+
"neptune_config",
183+
"nltk",
184+
"numpy",
185+
"omegaconf",
186+
"pandas",
187+
"pqdm",
188+
"pydantic",
189+
"pytest",
190+
"pytorch_lightning",
191+
"requests",
192+
"scipy",
193+
"setuptools",
194+
"shapely",
195+
"skimage",
196+
"sklearn",
197+
"streamlit",
198+
"torch",
199+
"torchvision",
200+
"tqdm",
201+
"typer",
202+
]

0 commit comments

Comments
 (0)