Skip to content

Commit 290bdde

Browse files
committed
chore: optimize CodeRabbit configuration for Python/FastAPI project
- Add comprehensive path-based review instructions for all project layers - Configure Python-specific linting tools (ruff, flake8, pylint) - Disable irrelevant tools (JS/TS, PHP, Go, Ruby, Swift, etc.) - Add project-specific path filters to ignore cache and build artifacts - Enable auto-review for master/main branches with WIP exclusion - Configure docstring and unit test generation with pytest patterns - Adjust pre-merge check thresholds (75% docstring coverage) - Add code guidelines for Python, requirements, Dockerfile, and YAML files
1 parent d5931a0 commit 290bdde

1 file changed

Lines changed: 200 additions & 97 deletions

File tree

.coderabbit.yaml

Lines changed: 200 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1+
# CodeRabbit Configuration
2+
# Optimized for Python 3.13 / FastAPI RESTful API project
3+
14
language: en-US
2-
tone_instructions: ""
35
early_access: true
46
enable_free_tier: true
5-
inheritance: false
7+
68
reviews:
79
profile: chill
810
request_changes_workflow: false
911
high_level_summary: true
10-
high_level_summary_instructions: ""
1112
high_level_summary_placeholder: "@coderabbitai summary"
12-
high_level_summary_in_walkthrough: false
13-
auto_title_placeholder: "@coderabbitai"
14-
auto_title_instructions: ""
1513
review_status: true
1614
commit_status: true
1715
fail_commit_status: false
@@ -21,175 +19,280 @@ reviews:
2119
estimate_code_review_effort: true
2220
assess_linked_issues: true
2321
related_issues: true
24-
related_prs: false
25-
suggested_labels: false
26-
labeling_instructions: []
22+
related_prs: true
23+
suggested_labels: true
2724
auto_apply_labels: false
2825
suggested_reviewers: false
2926
auto_assign_reviewers: false
3027
in_progress_fortune: true
3128
poem: false
32-
enable_prompt_for_ai_agents: true
33-
path_filters: []
34-
path_instructions: []
3529
abort_on_close: true
36-
disable_cache: false
30+
31+
# Path-based review instructions for this Python/FastAPI project
32+
path_instructions:
33+
- path: "**/*.py"
34+
instructions: |
35+
- Follow PEP 8 style guide and Black formatting (88 char line length)
36+
- Use type hints for function parameters and return values
37+
- Follow async/await patterns for all I/O operations
38+
- Use Google-style docstrings for modules, classes, and functions
39+
- Verify imports follow proper grouping (stdlib → third-party → local)
40+
- Check that SQLAlchemy 2.0+ style is used (select() not legacy Query)
41+
42+
- path: "routes/**/*.py"
43+
instructions: |
44+
- Routes should be thin - delegate to services
45+
- Verify proper HTTP status codes and FastAPI response models
46+
- Check that dependency injection is used (Depends(generate_async_session))
47+
- Ensure Pydantic models are used for request/response validation
48+
- Validate async route handlers (async def)
49+
- Check for proper cache headers (X-Cache: HIT/MISS)
50+
51+
- path: "services/**/*.py"
52+
instructions: |
53+
- Services should contain business logic
54+
- Verify async database operations via repositories/database layer
55+
- Check cache invalidation on POST/PUT/DELETE operations
56+
- Ensure proper error handling with try/except where needed
57+
- Validate that Pydantic models are converted properly (model_dump())
58+
59+
- path: "databases/**/*.py"
60+
instructions: |
61+
- Verify AsyncSession usage with proper async context managers
62+
- Check that async_session generator uses yield pattern
63+
- Ensure SQLAlchemy engine is configured with aiosqlite
64+
- Validate database initialization in lifespan handler
65+
66+
- path: "schemas/**/*.py"
67+
instructions: |
68+
- SQLAlchemy ORM schemas should use declarative base
69+
- Check proper column types and constraints
70+
- Verify table names are explicitly set
71+
- Ensure relationships are defined if needed
72+
73+
- path: "models/**/*.py"
74+
instructions: |
75+
- Pydantic models should use Field for validation
76+
- Verify camelCase aliasing with Config.alias_generator = to_camel
77+
- Check that validation constraints match business rules
78+
- Ensure models are separate from database schemas
79+
80+
- path: "tests/**/*.py"
81+
instructions: |
82+
- Tests should use pytest with fixtures from conftest.py
83+
- Verify test naming follows given_when_then pattern
84+
- Check that TestClient is used for endpoint testing
85+
- Ensure test data uses stubs (e.g., player_stub.py)
86+
- Tests should use async test functions where appropriate
87+
- Validate coverage targets (80% minimum)
88+
89+
- path: "main.py"
90+
instructions: |
91+
- Verify FastAPI app initialization with proper settings
92+
- Check lifespan handler for database initialization
93+
- Ensure router registration is correct
94+
- Validate CORS and middleware configuration
95+
96+
- path: "**/Dockerfile"
97+
instructions: |
98+
- Verify Python 3.13 base image (python:3.13-alpine)
99+
- Check multi-stage builds for optimization
100+
- Ensure non-root user is used for security
101+
- Validate HEALTHCHECK instruction is present
102+
- Check that requirements are installed in correct order
103+
104+
- path: "requirements*.txt"
105+
instructions: |
106+
- Verify pinned versions for reproducibility
107+
- Check separation: requirements.txt (runtime), requirements-test.txt, requirements-lint.txt
108+
- Ensure dependencies are up to date with security patches
109+
110+
- path: "pyproject.toml"
111+
instructions: |
112+
- Verify Black configuration (line-length = 88, target-version = py313)
113+
- Check pytest configuration matches test execution
114+
- Ensure tool configurations are consistent with CI
115+
116+
# Ignore patterns for this project
117+
path_filters:
118+
- "!**/__pycache__/**"
119+
- "!**/.pytest_cache/**"
120+
- "!**/htmlcov/**"
121+
- "!**/*.pyc"
122+
- "!**/.venv/**"
123+
- "!**/venv/**"
124+
- "!**/storage/**"
125+
- "!**/*.db"
126+
- "!**/*.db-shm"
127+
- "!**/*.db-wal"
128+
- "!**/assets/**"
129+
- "!**/postman_collections/**"
130+
37131
auto_review:
38132
enabled: true
39133
auto_incremental_review: true
40-
ignore_title_keywords: []
41-
labels:
42-
- planning
134+
ignore_title_keywords:
135+
- "WIP"
136+
- "DO NOT REVIEW"
137+
- "wip"
43138
drafts: false
44-
base_branches: []
45-
ignore_usernames: []
139+
base_branches:
140+
- master
141+
- main
142+
46143
finishing_touches:
47144
docstrings:
48145
enabled: true
49146
unit_tests:
50147
enabled: true
148+
51149
pre_merge_checks:
52150
docstrings:
53151
mode: warning
54-
threshold: 80
152+
threshold: 75
55153
title:
56154
mode: warning
57-
requirements: ""
155+
requirements: |
156+
- Use Conventional Commits format (feat:, fix:, chore:, docs:, test:, refactor:)
157+
- Keep under 80 characters
158+
- Be descriptive and specific
58159
description:
59160
mode: warning
60161
issue_assessment:
61162
mode: warning
62-
custom_checks: []
163+
63164
tools:
64-
ast-grep:
65-
rule_dirs: []
66-
util_dirs: []
67-
essential_rules: true
68-
packages: []
69-
shellcheck:
70-
enabled: true
165+
# Relevant tools for Python projects
71166
ruff:
72167
enabled: true
73-
markdownlint:
168+
flake8:
74169
enabled: true
75-
github-checks:
170+
pylint:
76171
enabled: true
77-
timeout_ms: 90000
78-
languagetool:
172+
gitleaks:
79173
enabled: true
80-
enabled_rules: []
81-
disabled_rules: []
82-
enabled_categories: []
83-
disabled_categories: []
84-
enabled_only: false
85-
level: default
86-
biome:
174+
checkov:
87175
enabled: true
88176
hadolint:
89177
enabled: true
90-
swiftlint:
178+
yamllint:
91179
enabled: true
92-
phpstan:
180+
actionlint:
93181
enabled: true
94-
level: default
95-
phpmd:
182+
semgrep:
96183
enabled: true
97-
phpcs:
184+
markdownlint:
98185
enabled: true
99-
golangci-lint:
186+
github-checks:
100187
enabled: true
101-
yamllint:
188+
timeout_ms: 120000
189+
dotenvLint:
102190
enabled: true
103-
gitleaks:
191+
checkmake:
104192
enabled: true
105-
checkov:
193+
osvScanner:
106194
enabled: true
195+
196+
# Disable irrelevant tools for Python project
197+
shellcheck:
198+
enabled: false
199+
biome:
200+
enabled: false
201+
swiftlint:
202+
enabled: false
203+
phpstan:
204+
enabled: false
205+
phpmd:
206+
enabled: false
207+
phpcs:
208+
enabled: false
209+
golangci-lint:
210+
enabled: false
107211
detekt:
108-
enabled: true
212+
enabled: false
109213
eslint:
110-
enabled: true
111-
flake8:
112-
enabled: true
113-
fortitudeLint:
114-
enabled: true
214+
enabled: false
115215
rubocop:
116-
enabled: true
216+
enabled: false
117217
buf:
118-
enabled: true
218+
enabled: false
119219
regal:
120-
enabled: true
121-
actionlint:
122-
enabled: true
220+
enabled: false
123221
pmd:
124-
enabled: true
222+
enabled: false
125223
clang:
126-
enabled: true
224+
enabled: false
127225
cppcheck:
128-
enabled: true
129-
semgrep:
130-
enabled: true
131-
circleci:
132-
enabled: true
226+
enabled: false
133227
clippy:
134-
enabled: true
228+
enabled: false
135229
sqlfluff:
136-
enabled: true
230+
enabled: false
137231
prismaLint:
138-
enabled: true
139-
pylint:
140-
enabled: true
232+
enabled: false
141233
oxc:
142-
enabled: true
234+
enabled: false
143235
shopifyThemeCheck:
144-
enabled: true
236+
enabled: false
145237
luacheck:
146-
enabled: true
238+
enabled: false
147239
brakeman:
148-
enabled: true
149-
dotenvLint:
150-
enabled: true
240+
enabled: false
151241
htmlhint:
152-
enabled: true
153-
checkmake:
154-
enabled: true
155-
osvScanner:
156-
enabled: true
242+
enabled: false
243+
languagetool:
244+
enabled: false
245+
circleci:
246+
enabled: false
247+
fortitudeLint:
248+
enabled: false
249+
157250
chat:
158251
art: true
159252
auto_reply: true
160-
integrations:
161-
jira:
162-
usage: disabled
163-
linear:
164-
usage: disabled
253+
165254
knowledge_base:
166255
opt_out: false
167256
web_search:
168257
enabled: true
169258
code_guidelines:
170259
enabled: true
171-
filePatterns: []
260+
filePatterns:
261+
- "**/*.py"
262+
- "**/requirements*.txt"
263+
- "**/pyproject.toml"
264+
- "**/Dockerfile"
265+
- "**/*.{yml,yaml}"
172266
learnings:
173267
scope: auto
174268
issues:
175269
scope: auto
176-
jira:
177-
usage: disabled
178-
project_keys: []
179-
linear:
180-
usage: disabled
181-
team_keys: []
182270
pull_requests:
183271
scope: auto
184272
mcp:
185273
usage: auto
186-
disabled_servers: []
274+
187275
code_generation:
188276
docstrings:
189277
language: en-US
190-
path_instructions: []
278+
path_instructions:
279+
- path: "**/*.py"
280+
instructions: |
281+
- Use Google-style docstrings with Args, Returns, Raises sections
282+
- Keep documentation concise and meaningful
283+
- Include type information in docstrings when helpful
284+
- Document async functions and their async behavior
191285
unit_tests:
192-
path_instructions: []
286+
path_instructions:
287+
- path: "tests/**/*.py"
288+
instructions: |
289+
- Use pytest framework with async support (pytest-asyncio)
290+
- Follow given_when_then or arrange_act_assert patterns
291+
- Use fixtures from conftest.py for TestClient
292+
- Use test stubs for consistent test data
293+
- Ensure async tests are properly decorated
294+
- Target 80% code coverage minimum
295+
193296
issue_enrichment:
194297
auto_enrich:
195298
enabled: true

0 commit comments

Comments
 (0)