@the-bearded-bear/claude-craft 3.5.0 → 4.0.0-next.43532ae

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,572 @@
1
+ # Code Quality Tools - Python
2
+
3
+ ## Ruff - Fast Python Linter & Formatter
4
+
5
+ ### Installation
6
+
7
+ ```bash
8
+ pip install ruff
9
+ # Or with pipx for global installation
10
+ pipx install ruff
11
+ ```
12
+
13
+ ### pyproject.toml Configuration
14
+
15
+ ```toml
16
+ [tool.ruff]
17
+ # Target Python version
18
+ target-version = "py312"
19
+
20
+ # Line length
21
+ line-length = 88
22
+
23
+ # Exclude directories
24
+ exclude = [
25
+ ".git",
26
+ "__pycache__",
27
+ ".venv",
28
+ "venv",
29
+ ".eggs",
30
+ "build",
31
+ "dist",
32
+ ".mypy_cache",
33
+ ".pytest_cache",
34
+ ]
35
+
36
+ [tool.ruff.lint]
37
+ # Enable rules
38
+ select = [
39
+ "E", # pycodestyle errors
40
+ "W", # pycodestyle warnings
41
+ "F", # Pyflakes
42
+ "I", # isort
43
+ "B", # flake8-bugbear
44
+ "C4", # flake8-comprehensions
45
+ "UP", # pyupgrade
46
+ "ARG", # flake8-unused-arguments
47
+ "SIM", # flake8-simplify
48
+ "PTH", # flake8-use-pathlib
49
+ "ERA", # eradicate (commented-out code)
50
+ "RUF", # Ruff-specific rules
51
+ "S", # flake8-bandit (security)
52
+ "T20", # flake8-print
53
+ "PL", # Pylint
54
+ "TRY", # tryceratops
55
+ "PERF", # Perflint
56
+ "ASYNC", # flake8-async
57
+ ]
58
+
59
+ # Ignore specific rules
60
+ ignore = [
61
+ "E501", # Line too long (handled by formatter)
62
+ "S101", # Use of assert (needed for tests)
63
+ "PLR0913", # Too many arguments
64
+ ]
65
+
66
+ # Per-file ignores
67
+ [tool.ruff.lint.per-file-ignores]
68
+ "tests/**/*.py" = [
69
+ "S101", # Allow assert in tests
70
+ "ARG", # Allow unused arguments in fixtures
71
+ "PLR2004", # Magic values in tests
72
+ ]
73
+ "**/migrations/**/*.py" = [
74
+ "ALL", # Ignore migrations
75
+ ]
76
+
77
+ [tool.ruff.lint.isort]
78
+ # Import sorting configuration
79
+ known-first-party = ["src", "app"]
80
+ section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
81
+ force-single-line = false
82
+ combine-as-imports = true
83
+
84
+ [tool.ruff.format]
85
+ # Formatting options
86
+ quote-style = "double"
87
+ indent-style = "space"
88
+ skip-magic-trailing-comma = false
89
+ line-ending = "auto"
90
+ ```
91
+
92
+ ### CLI Commands
93
+
94
+ ```bash
95
+ # Check for issues
96
+ ruff check .
97
+
98
+ # Fix auto-fixable issues
99
+ ruff check --fix .
100
+
101
+ # Format code
102
+ ruff format .
103
+
104
+ # Check formatting without changes
105
+ ruff format --check .
106
+
107
+ # Watch mode for development
108
+ ruff check --watch .
109
+ ```
110
+
111
+ ## mypy - Static Type Checking
112
+
113
+ ### Installation
114
+
115
+ ```bash
116
+ pip install mypy
117
+ # With common stubs
118
+ pip install types-requests types-python-dateutil types-redis
119
+ ```
120
+
121
+ ### pyproject.toml Configuration
122
+
123
+ ```toml
124
+ [tool.mypy]
125
+ python_version = "3.12"
126
+ strict = true
127
+ warn_return_any = true
128
+ warn_unused_configs = true
129
+ disallow_untyped_defs = true
130
+ disallow_incomplete_defs = true
131
+ check_untyped_defs = true
132
+ disallow_untyped_decorators = true
133
+ no_implicit_optional = true
134
+ warn_redundant_casts = true
135
+ warn_unused_ignores = true
136
+ warn_no_return = true
137
+ warn_unreachable = true
138
+ show_error_codes = true
139
+ show_column_numbers = true
140
+
141
+ # Plugins
142
+ plugins = [
143
+ "pydantic.mypy",
144
+ "sqlalchemy.ext.mypy.plugin",
145
+ ]
146
+
147
+ # Per-module overrides
148
+ [[tool.mypy.overrides]]
149
+ module = "tests.*"
150
+ disallow_untyped_defs = false
151
+ disallow_incomplete_defs = false
152
+
153
+ [[tool.mypy.overrides]]
154
+ module = "migrations.*"
155
+ ignore_errors = true
156
+ ```
157
+
158
+ ### CLI Commands
159
+
160
+ ```bash
161
+ # Run type checking
162
+ mypy src/
163
+
164
+ # Generate report
165
+ mypy src/ --html-report mypy-report
166
+
167
+ # Check specific file
168
+ mypy src/main.py
169
+
170
+ # Strict mode
171
+ mypy --strict src/
172
+ ```
173
+
174
+ ## pytest - Testing Framework
175
+
176
+ ### Installation
177
+
178
+ ```bash
179
+ pip install pytest pytest-cov pytest-asyncio pytest-xdist httpx
180
+ ```
181
+
182
+ ### pyproject.toml Configuration
183
+
184
+ ```toml
185
+ [tool.pytest.ini_options]
186
+ testpaths = ["tests"]
187
+ python_files = ["test_*.py", "*_test.py"]
188
+ python_functions = ["test_*"]
189
+ python_classes = ["Test*"]
190
+ asyncio_mode = "auto"
191
+ addopts = [
192
+ "-v",
193
+ "--strict-markers",
194
+ "--tb=short",
195
+ "-ra",
196
+ "--cov=src",
197
+ "--cov-report=term-missing",
198
+ "--cov-report=html",
199
+ "--cov-report=xml",
200
+ "--cov-fail-under=80",
201
+ ]
202
+ markers = [
203
+ "slow: marks tests as slow",
204
+ "integration: marks tests as integration tests",
205
+ "unit: marks tests as unit tests",
206
+ ]
207
+ filterwarnings = [
208
+ "error",
209
+ "ignore::DeprecationWarning",
210
+ ]
211
+ ```
212
+
213
+ ### CLI Commands
214
+
215
+ ```bash
216
+ # Run all tests
217
+ pytest
218
+
219
+ # Run with coverage
220
+ pytest --cov=src --cov-report=html
221
+
222
+ # Run specific test file
223
+ pytest tests/test_user.py
224
+
225
+ # Run tests matching pattern
226
+ pytest -k "test_user"
227
+
228
+ # Run in parallel
229
+ pytest -n auto
230
+
231
+ # Run only failed tests
232
+ pytest --lf
233
+
234
+ # Verbose output
235
+ pytest -vv
236
+ ```
237
+
238
+ ## pre-commit - Git Hooks
239
+
240
+ ### Installation
241
+
242
+ ```bash
243
+ pip install pre-commit
244
+ pre-commit install
245
+ ```
246
+
247
+ ### .pre-commit-config.yaml
248
+
249
+ ```yaml
250
+ repos:
251
+ - repo: https://github.com/astral-sh/ruff-pre-commit
252
+ rev: v0.8.0
253
+ hooks:
254
+ - id: ruff
255
+ args: [--fix]
256
+ - id: ruff-format
257
+
258
+ - repo: https://github.com/pre-commit/mirrors-mypy
259
+ rev: v1.13.0
260
+ hooks:
261
+ - id: mypy
262
+ additional_dependencies:
263
+ - types-requests
264
+ - pydantic
265
+
266
+ - repo: https://github.com/pre-commit/pre-commit-hooks
267
+ rev: v5.0.0
268
+ hooks:
269
+ - id: trailing-whitespace
270
+ - id: end-of-file-fixer
271
+ - id: check-yaml
272
+ - id: check-json
273
+ - id: check-added-large-files
274
+ args: ['--maxkb=1000']
275
+ - id: check-merge-conflict
276
+ - id: detect-private-key
277
+ - id: no-commit-to-branch
278
+ args: ['--branch', 'main', '--branch', 'master']
279
+
280
+ - repo: https://github.com/commitizen-tools/commitizen
281
+ rev: v4.1.0
282
+ hooks:
283
+ - id: commitizen
284
+ stages: [commit-msg]
285
+
286
+ - repo: local
287
+ hooks:
288
+ - id: pytest-check
289
+ name: pytest
290
+ entry: pytest tests/ -x --no-cov
291
+ language: system
292
+ pass_filenames: false
293
+ always_run: true
294
+ ```
295
+
296
+ ### CLI Commands
297
+
298
+ ```bash
299
+ # Install hooks
300
+ pre-commit install
301
+
302
+ # Run on all files
303
+ pre-commit run --all-files
304
+
305
+ # Update hooks
306
+ pre-commit autoupdate
307
+
308
+ # Skip hooks temporarily
309
+ git commit --no-verify -m "message"
310
+ ```
311
+
312
+ ## Bandit - Security Linter
313
+
314
+ ### Installation
315
+
316
+ ```bash
317
+ pip install bandit[toml]
318
+ ```
319
+
320
+ ### pyproject.toml Configuration
321
+
322
+ ```toml
323
+ [tool.bandit]
324
+ exclude_dirs = ["tests", "venv", ".venv"]
325
+ skips = ["B101"] # Skip assert warnings
326
+
327
+ [tool.bandit.assert_used]
328
+ skips = ["*_test.py", "test_*.py"]
329
+ ```
330
+
331
+ ### CLI Commands
332
+
333
+ ```bash
334
+ # Run security scan
335
+ bandit -r src/
336
+
337
+ # Output to file
338
+ bandit -r src/ -f json -o bandit-report.json
339
+
340
+ # Severity filter
341
+ bandit -r src/ -ll # Only medium and high
342
+ ```
343
+
344
+ ## Coverage.py - Code Coverage
345
+
346
+ ### pyproject.toml Configuration
347
+
348
+ ```toml
349
+ [tool.coverage.run]
350
+ source = ["src"]
351
+ branch = true
352
+ omit = [
353
+ "*/tests/*",
354
+ "*/__pycache__/*",
355
+ "*/migrations/*",
356
+ "*/.venv/*",
357
+ ]
358
+
359
+ [tool.coverage.report]
360
+ exclude_lines = [
361
+ "pragma: no cover",
362
+ "def __repr__",
363
+ "raise NotImplementedError",
364
+ "if TYPE_CHECKING:",
365
+ "if __name__ == .__main__.:",
366
+ "@abstractmethod",
367
+ ]
368
+ fail_under = 80
369
+ show_missing = true
370
+
371
+ [tool.coverage.html]
372
+ directory = "htmlcov"
373
+ ```
374
+
375
+ ## EditorConfig
376
+
377
+ ### .editorconfig
378
+
379
+ ```ini
380
+ root = true
381
+
382
+ [*]
383
+ charset = utf-8
384
+ end_of_line = lf
385
+ insert_final_newline = true
386
+ trim_trailing_whitespace = true
387
+ indent_style = space
388
+ indent_size = 4
389
+
390
+ [*.py]
391
+ indent_size = 4
392
+ max_line_length = 88
393
+
394
+ [*.{yml,yaml,toml,json}]
395
+ indent_size = 2
396
+
397
+ [Makefile]
398
+ indent_style = tab
399
+ ```
400
+
401
+ ## VS Code Configuration
402
+
403
+ ### .vscode/settings.json
404
+
405
+ ```json
406
+ {
407
+ "python.defaultInterpreterPath": ".venv/bin/python",
408
+ "python.analysis.typeCheckingMode": "strict",
409
+
410
+ "[python]": {
411
+ "editor.defaultFormatter": "charliermarsh.ruff",
412
+ "editor.formatOnSave": true,
413
+ "editor.codeActionsOnSave": {
414
+ "source.fixAll.ruff": "explicit",
415
+ "source.organizeImports.ruff": "explicit"
416
+ }
417
+ },
418
+
419
+ "python.testing.pytestEnabled": true,
420
+ "python.testing.pytestArgs": ["tests"],
421
+
422
+ "mypy.runUsingActiveInterpreter": true,
423
+
424
+ "files.exclude": {
425
+ "**/__pycache__": true,
426
+ "**/.pytest_cache": true,
427
+ "**/.mypy_cache": true,
428
+ "**/*.egg-info": true
429
+ }
430
+ }
431
+ ```
432
+
433
+ ### .vscode/extensions.json
434
+
435
+ ```json
436
+ {
437
+ "recommendations": [
438
+ "ms-python.python",
439
+ "ms-python.vscode-pylance",
440
+ "charliermarsh.ruff",
441
+ "ms-python.mypy-type-checker",
442
+ "tamasfe.even-better-toml",
443
+ "redhat.vscode-yaml",
444
+ "streetsidesoftware.code-spell-checker"
445
+ ]
446
+ }
447
+ ```
448
+
449
+ ## GitHub Actions CI
450
+
451
+ ### .github/workflows/ci.yml
452
+
453
+ ```yaml
454
+ name: CI
455
+
456
+ on:
457
+ push:
458
+ branches: [main, develop]
459
+ pull_request:
460
+ branches: [main, develop]
461
+
462
+ jobs:
463
+ quality:
464
+ runs-on: ubuntu-latest
465
+
466
+ steps:
467
+ - uses: actions/checkout@v4
468
+
469
+ - name: Set up Python
470
+ uses: actions/setup-python@v5
471
+ with:
472
+ python-version: '3.12'
473
+ cache: 'pip'
474
+
475
+ - name: Install dependencies
476
+ run: |
477
+ python -m pip install --upgrade pip
478
+ pip install -e ".[dev]"
479
+
480
+ - name: Lint with Ruff
481
+ run: ruff check .
482
+
483
+ - name: Format check with Ruff
484
+ run: ruff format --check .
485
+
486
+ - name: Type check with mypy
487
+ run: mypy src/
488
+
489
+ - name: Security check with Bandit
490
+ run: bandit -r src/
491
+
492
+ - name: Test with pytest
493
+ run: pytest --cov=src --cov-report=xml
494
+
495
+ - name: Upload coverage
496
+ uses: codecov/codecov-action@v4
497
+ with:
498
+ files: coverage.xml
499
+ ```
500
+
501
+ ## Makefile
502
+
503
+ ```makefile
504
+ .PHONY: install lint format test coverage clean
505
+
506
+ install:
507
+ pip install -e ".[dev]"
508
+ pre-commit install
509
+
510
+ lint:
511
+ ruff check .
512
+ mypy src/
513
+
514
+ format:
515
+ ruff format .
516
+ ruff check --fix .
517
+
518
+ test:
519
+ pytest
520
+
521
+ coverage:
522
+ pytest --cov=src --cov-report=html
523
+ open htmlcov/index.html
524
+
525
+ security:
526
+ bandit -r src/
527
+
528
+ clean:
529
+ rm -rf .pytest_cache .mypy_cache .ruff_cache htmlcov .coverage
530
+ find . -type d -name __pycache__ -exec rm -rf {} +
531
+
532
+ quality: format lint test security
533
+ @echo "All quality checks passed!"
534
+ ```
535
+
536
+ ## Quality Checklist
537
+
538
+ ### Before Each Commit
539
+
540
+ - [ ] Code formatted with Ruff
541
+ - [ ] No linting errors
542
+ - [ ] No type errors (mypy)
543
+ - [ ] Tests pass
544
+ - [ ] No security issues (bandit)
545
+ - [ ] Commit message follows Conventional Commits
546
+
547
+ ### Before Each Push
548
+
549
+ - [ ] All tests pass
550
+ - [ ] Coverage >= 80%
551
+ - [ ] No TODO/FIXME in committed code
552
+ - [ ] Documentation updated
553
+
554
+ ### Quality Metrics Goals
555
+
556
+ - **Test Coverage**: >= 80%
557
+ - **Type Coverage**: 100%
558
+ - **Linting Errors**: 0
559
+ - **Security Issues**: 0
560
+ - **Cyclomatic Complexity**: < 10 per function
561
+
562
+ ## Conclusion
563
+
564
+ Quality tools enable:
565
+
566
+ 1. **Consistency**: Uniform code across the team
567
+ 2. **Quality**: Early error detection
568
+ 3. **Security**: Vulnerability detection
569
+ 4. **Maintainability**: Easy-to-maintain code
570
+ 5. **Confidence**: Deploy with confidence
571
+
572
+ **Golden rule**: Code quality must be automated and non-negotiable.