-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyproject.toml
More file actions
832 lines (743 loc) · 30.7 KB
/
pyproject.toml
File metadata and controls
832 lines (743 loc) · 30.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "specfact-cli"
version = "0.46.4"
description = "The swiss knife CLI for agile DevOps teams. Keep backlog, specs, tests, and code in sync with validation and contract enforcement for new projects and long-lived codebases."
readme = "README.md"
requires-python = ">=3.11"
license = { file = "LICENSE" } # Apache License 2.0
authors = [
]
keywords = [
"agile",
"devops",
"backlog",
"scrum",
"kanban",
"safe",
"ceremonies",
"existing-code",
"legacy",
"modernization",
"specs",
"contracts",
"validation",
"policy-as-code",
"tdd",
"contract-driven-development",
"property-based-testing",
"crosshair",
"icontract",
"beartype",
"cli",
"specfact",
]
# Install profiles (PEP 621 extras):
# - `pip install specfact-cli` — minimal runtime (CLI, registry, contracts via icontract/beartype, no CrossHair/Hypothesis wheels).
# - `pip install specfact-cli[contracts]` — add CrossHair + Hypothesis for contract exploration / property tooling.
# - `pip install specfact-cli[dev]` — contributors: pytest, linters, and same contract tools as [contracts] (see dev list).
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License", # Apache License 2.0
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
"Topic :: Software Development :: Libraries :: Python Modules"
]
dependencies = [
# Core dependencies
"pydantic>=2.12.3",
"typing-extensions>=4.15.0",
"PyYAML>=6.0.3",
"requests>=2.32.3",
"azure-identity>=1.17.1",
"cryptography>=43.0.0",
"packaging>=24.0",
# PEP 440 / markers for module installer and registry (do not rely on transitive pins only)
# CLI framework
# Typer 0.24+ requires click>=8.2.1 (generic Choice[...]); dev semgrep pins click~=8.1.8 — cap Typer.
"typer>=0.20.0,<0.24",
"rich>=13.5.2,<13.6.0", # Compatible with semgrep (requires rich~=13.5.2)
"questionary>=2.0.1", # Interactive prompts with arrow key navigation
# Template engine
"jinja2>=3.1.6",
# Graph analysis
"networkx>=3.4.2",
"graphviz>=0.20.1", # Graph visualization (requires system Graphviz: apt-get install graphviz)
# Git operations
# gitpython: CVE history (CVE-2022-24439, CVE-2023-41040, CVE-2023-40590). Phase 2: replace with dulwich.
"gitpython>=3.1.45",
# YAML utilities
"ruamel.yaml>=0.18.16",
# Schema validation
"jsonschema>=4.23.0",
# VS Code settings.json is JSONC (comments + trailing commas); commentjson (MIT) strips them, delegates to stdlib json
"commentjson>=0.9.0",
# Contract-First (runtime decorators; exploration tools are optional extra `contracts`)
"icontract>=2.7.1", # Design-by-contract decorators
"beartype>=0.22.4", # Runtime type checking
# File system watching
"watchdog>=6.0.0",
# Telemetry (opt-in; only active when SPECFACT_TELEMETRY_OPT_IN=true)
"opentelemetry-sdk>=1.27.0",
"opentelemetry-exporter-otlp-proto-http>=1.27.0",
]
[project.optional-dependencies]
contracts = [
"crosshair-tool>=0.0.97",
"hypothesis>=6.142.4",
]
dev = [
"setuptools>=69.0.0,<82",
"pytest>=8.4.2",
"pytest-cov>=7.0.0",
"pytest-mock>=3.15.1",
"pytest-asyncio>=1.2.0",
"pytest-xdist>=3.8.0",
"basedpyright>=1.32.1",
"isort>=7.0.0",
"pylint>=4.0.2", # GPL-2.0-or-later — dev-only exception (not in module manifests). Phase 2: replace with ruff --select ALL.
"ruff>=0.14.2",
"radon>=6.0.1",
"tomlkit>=0.13.3", # Style-preserving TOML library (recommended successor to pytoml)
"types-PyYAML>=6.0.12.20250516",
"pip-tools>=7.5.1",
"semgrep>=1.144.0", # LGPL-2.1 — required for code analysis; invoked as subprocess (accepted exception)
# Same contract exploration stack as [contracts] (extras cannot self-reference)
"crosshair-tool>=0.0.97",
"hypothesis>=6.142.4",
# Contract-First Development Dependencies (dev)
"icontract>=2.7.1",
"beartype>=0.22.4",
# Enhanced Analysis Tools (for local development)
"graphviz>=0.20.1", # Graph visualization (requires system Graphviz: apt-get install graphviz)
"pycg==0.0.7", # Python call graph analysis (Apache-2.0; replaces removed GPL-2.0 pyan3; pin avoids 0.0.8)
# Removed from dev: pyan3 (GPL-2.0) and bearer (wrong PyPI package; SaaS auth, not scanner)
# syft removed — wrong PyPI package (OpenMined ML framework, not Anchore SBOM)
"bandit>=1.7.0", # SAST scanner (MIT)
"pip-licenses>=4.0.0", # License enumeration for compliance gate (MIT)
"pip-audit>=2.0.0", # CVE audit via OSV database (Apache-2.0)
# pylint: GPL-2.0-or-later — dev-only exception (not in module manifests). Phase 2: replace with ruff --select ALL.
]
scanning = [
"semgrep>=1.144.0", # Optional: Only needed for code scanning features
]
enhanced-analysis = [
"graphviz>=0.20.1", # Graph visualization (requires system Graphviz: apt-get install graphviz)
"pycg==0.0.7", # Python call graph analysis (Apache-2.0; replaces removed GPL-2.0 pyan3; pin avoids 0.0.8)
# Removed from enhanced-analysis: pyan3 (GPL-2.0), bearer, and syft (wrong PyPI packages)
]
# Note: Specmatic integration (specfact spec commands) requires the Specmatic CLI tool
# to be installed separately. Specmatic is a Java-based CLI tool, not a Python package.
# Install from: https://docs.specmatic.io/
# The specfact spec commands will check for Specmatic availability and provide
# helpful error messages if it's not found.
# Add other optional dependency groups from your original if they existed and are still needed (e.g., server, client, devtools, full from tpl)
[project.urls]
Homepage = "https://github.com/nold-ai/specfact-cli"
Repository = "https://github.com/nold-ai/specfact-cli.git"
Documentation = "https://github.com/nold-ai/specfact-cli#readme"
Issues = "https://github.com/nold-ai/specfact-cli/issues"
Trademarks = "https://github.com/nold-ai/specfact-cli/blob/main/TRADEMARKS.md"
[project.scripts]
specfact = "specfact_cli.cli:cli_main"
specfact-cli = "specfact_cli.cli:cli_main" # Alias for uvx compatibility
# [project.entry-points."pytest11"] # Add if you have pytest plugins
# specfact_test_plugin = "specfact_cli.pytest_plugin"
[tool.hatch.envs.default]
python = "3.12"
dependencies = [
# Semgrep pulls opentelemetry; setuptools 82+ may omit pkg_resources (breaks semgrep import chain)
"setuptools>=69.0.0,<82",
"pip-tools",
"pytest",
"pytest-cov",
"pytest-mock",
"pytest-xdist",
"pre-commit",
# Ensure format/lint tools are available in the hatch env
"isort>=7.0.0",
"basedpyright>=1.32.1",
"pylint>=4.0.2",
"ruff>=0.14.2",
"radon>=6.0.1",
"yamllint>=1.37.1", # GPL-3.0-or-later — dev/test-only exception. Phase 2: replace with non-GPL YAML lint path.
"semgrep>=1.144.0", # LGPL-2.1 — required for code analysis; invoked as subprocess (accepted exception)
# Contract-First Development Dependencies
"icontract>=2.7.1",
"beartype>=0.22.4",
"crosshair-tool>=0.0.97",
"hypothesis>=6.142.4",
# Enhanced Analysis Tools (for local development)
"graphviz>=0.20.1", # Graph visualization (requires system Graphviz: apt-get install graphviz)
"pycg==0.0.7", # Python call graph analysis (Apache-2.0; replaces removed GPL-2.0 pyan3; pin avoids 0.0.8)
# Removed from Hatch default: pyan3 (GPL-2.0), bearer, and syft (wrong PyPI packages)
"bandit>=1.7.0", # SAST scanner (MIT)
"pip-licenses>=4.0.0", # License enumeration for compliance gate (MIT)
"pip-audit>=2.0.0", # CVE audit via OSV database (Apache-2.0)
# pylint: GPL-2.0-or-later — dev-only exception (not in module manifests). Phase 2: replace with ruff --select ALL.
]
[tool.hatch.envs.default.scripts]
validate-prompts = "python tools/validate_prompts.py"
# Security and license compliance gates
bandit-scan = "bandit -r src/ -ll"
license-check = "python scripts/check_license_compliance.py"
# Wrap pip-audit so JSON parsing and CVSS threshold checks fail closed.
security-audit = "python scripts/security_audit_gate.py"
# Development scripts
test = "pytest {args}"
test-cov = "pytest --cov=src --cov-report=term-missing {args}"
type-check = "basedpyright --pythonpath $(python -c 'import sys; print(sys.executable)') {args}"
# basedpyright --level error: suppress warning noise in pre-commit (Block 1 runs `hatch run lint`).
lint = "ruff format . --check && basedpyright --level error --pythonpath $(python -c 'import sys; print(sys.executable)') && ruff check . && pylint src tests tools && python scripts/verify_safe_project_writes.py"
governance = "pylint src tests tools --reports=y --output-format=parseable"
format = "ruff check . --fix && ruff format ."
# Code scanning (Semgrep)
# Semgrep 1.38+ deprecated implicit .semgrep.yml discovery; always pass --config explicitly.
# Script must not be named `semgrep` (Hatch treats that as circular expansion with the semgrep CLI).
semgrep-full = "semgrep --config tools/semgrep {args}"
scan = "semgrep --config tools/semgrep/async.yml {args}"
scan-all = "semgrep --config tools/semgrep/async.yml ."
scan-json = "semgrep --config tools/semgrep/async.yml --json . > logs/semgrep-results.json"
scan-fix = "semgrep --config tools/semgrep/async.yml --autofix ."
# YAML and Workflow linting
yaml-fmt = "bash scripts/yaml-tools.sh fmt {args}"
yaml-lint = "bash scripts/yaml-tools.sh lint {args}"
workflows-fmt = "bash scripts/yaml-tools.sh workflows-fmt {args}"
workflows-lint = "bash scripts/yaml-tools.sh workflows-lint {args}"
yaml-fix-all = "bash scripts/yaml-tools.sh fix-all {args}"
yaml-check-all = "bash scripts/yaml-tools.sh check-all {args}"
# Docs validation (docs-12): command examples vs CLI; modules.specfact.io URLs in docs
check-docs-commands = "python scripts/check-docs-commands.py"
check-cross-site-links = "python scripts/check-cross-site-links.py"
doc-frontmatter-check = "python scripts/check_doc_frontmatter.py"
validate-agent-rule-signals = "python scripts/validate_agent_rule_applies_when.py"
check-version-sources = "python scripts/check_version_sources.py"
check-pypi-ahead = "python scripts/check_local_version_ahead_of_pypi.py"
release = "python scripts/check_local_version_ahead_of_pypi.py && python scripts/check_version_sources.py"
docs-validate = "python scripts/check-docs-commands.py && python scripts/check-cross-site-links.py --warn-only && python scripts/check_doc_frontmatter.py && python scripts/validate_agent_rule_applies_when.py"
# Legacy entry (kept for compatibility); prefer `workflows-lint` above
lint-workflows = "bash scripts/run_actionlint.sh {args}"
# Smart test coverage system
smart-test = "python tools/smart_test_coverage.py run {args}"
smart-test-check = "python tools/smart_test_coverage.py check"
smart-test-force = "python tools/smart_test_coverage.py force {args}"
smart-test-status = "python tools/smart_test_coverage.py status"
smart-test-threshold = "python tools/smart_test_coverage.py threshold"
smart-test-logs = "python tools/smart_test_coverage.py logs {args}"
smart-test-latest = "python tools/smart_test_coverage.py latest"
# Incremental testing levels (bottom-up approach)
smart-test-unit = "python tools/smart_test_coverage.py run --level unit {args}"
smart-test-folder = "python tools/smart_test_coverage.py run --level folder {args}"
smart-test-integration = "python tools/smart_test_coverage.py run --level integration {args}"
smart-test-e2e = "python tools/smart_test_coverage.py run --level e2e {args}"
smart-test-full = "python tools/smart_test_coverage.py run --level full {args}"
smart-test-auto = "python tools/smart_test_coverage.py run --level auto {args}"
# Bundled module verify (flags from scripts/module-verify-policy.sh via run_verify_modules_policy.sh)
verify-modules-signature = "bash scripts/run_verify_modules_policy.sh strict {args}"
verify-modules-signature-pr = "bash scripts/run_verify_modules_policy.sh pr {args}"
verify-modules-signature-push = "bash scripts/run_verify_modules_policy.sh push-orchestrator {args}"
# Module migration pre-deletion gate
verify-removal-gate = [
"python scripts/verify-bundle-published.py --modules project,plan,import_cmd,sync,migrate,backlog,policy_engine,analyze,drift,validate,repro,contract,spec,sdd,generate,enforce,patch_mode",
"hatch run verify-modules-signature",
]
export-change-github = "python scripts/export-change-to-github.py {args}"
# Contract-First Smart Test System Scripts
contract-test = "python tools/contract_first_smart_test.py run --level auto {args}"
contract-test-contracts = "python tools/contract_first_smart_test.py contracts"
contract-test-exploration = "python tools/contract_first_smart_test.py exploration {args}"
contract-test-exploration-fast = "python tools/contract_first_smart_test.py exploration --crosshair-fast {args}"
contract-test-scenarios = "python tools/contract_first_smart_test.py scenarios"
contract-test-e2e = "python tools/contract_first_smart_test.py run --level e2e {args}"
contract-test-full = "python tools/contract_first_smart_test.py run --level full {args}"
contract-test-status = "python tools/contract_first_smart_test.py status"
# Contract-First Development Scripts
contract-check = "python -m crosshair check {args}"
contract-explore = "python -m crosshair check {args} --timeout=60"
contract-migrate = "python tools/contract_migration_helper.py --analyze-module {args}"
contract-analyze = "python tools/migrate_tests_to_contracts.py --analyze --output logs/analysis/migration_analysis.json"
contract-prune = "python tools/migrate_tests_to_contracts.py --prune --dry-run"
# Pre-commit hooks
pre-commit-install = "bash scripts/setup-git-hooks.sh"
pre-commit-checks = "bash scripts/pre-commit-smart-checks.sh"
[tool.hatch.envs.py311]
python = "3.11"
[tool.hatch.envs.py311.scripts]
contract-test = "python tools/contract_first_smart_test.py run --level auto {args}"
contract-test-contracts = "python tools/contract_first_smart_test.py contracts"
contract-test-exploration = "python tools/contract_first_smart_test.py exploration {args}"
contract-test-exploration-fast = "python tools/contract_first_smart_test.py exploration --crosshair-fast {args}"
contract-test-scenarios = "python tools/contract_first_smart_test.py scenarios"
contract-test-e2e = "python tools/contract_first_smart_test.py run --level e2e {args}"
contract-test-full = "python tools/contract_first_smart_test.py run --level full {args}"
contract-test-status = "python tools/contract_first_smart_test.py status"
[tool.hatch.envs.hatch-test]
dependencies = [
"pytest>=8.4.2",
"pytest-mock>=3.15.1",
"pytest-asyncio>=1.2.0",
"pytest-xdist>=3.8.0",
"coverage[toml]>=7.7.1",
"pytest-timeout>=2.3.1",
"icontract>=2.7.1",
"beartype>=0.22.4",
"crosshair-tool>=0.0.97",
"hypothesis>=6.142.4",
"yamllint>=1.37.1", # GPL-3.0-or-later — dev/test-only exception. Phase 2: replace with non-GPL YAML lint path.
# Enhanced Analysis Tools (for testing)
"graphviz>=0.20.1", # Graph visualization (requires system Graphviz: apt-get install graphviz)
"pycg==0.0.7", # Python call graph analysis (Apache-2.0; replaces removed GPL-2.0 pyan3; pin avoids 0.0.8)
# Removed from Hatch test: pyan3 (GPL-2.0), bearer, and syft (wrong PyPI packages)
"commentjson>=0.9.0", # JSONC parser (MIT; replaces json5 for VS Code settings JSONC support)
]
dev-mode = true
parallel = true
[tool.hatch.envs.hatch-test.env-vars]
TOKENIZERS_PARALLELISM = "false" # Good practice if using HuggingFace tokenizers
[tool.hatch.envs.hatch-test.scripts]
# Adapted from template, adjust JUnit path if necessary
run = "pytest --timeout=30 --junitxml=logs/tests/junit/test-results.xml {args}" # 30s for code analysis/semgrep/graph tests under xdist
run-cov = "coverage run -m pytest --timeout=30 --junitxml=logs/tests/junit/test-results.xml {args}"
cov = "coverage run -m pytest --timeout=30 --junitxml=logs/tests/junit/test-results.xml {args}"
cov-combine = "coverage combine --quiet"
xml = "coverage xml -o logs/tests/coverage/coverage.xml"
run-html = "coverage html --data-file=logs/tests/coverage/.coverage -d logs/tests/coverage/html"
cov-report = "coverage report -m"
[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.11","3.12","3.13"] # Dropped 3.10 per project minimum >=3.11
[tool.coverage.run]
branch = true # Generally good to enable branch coverage
parallel = false # Set to true if you run tests in parallel
source = ["src", "tools"] # Source directory for specfact-cli and tools
relative_files = true
data_file = "logs/tests/coverage/.coverage"
omit = [
"*/tests/*",
"src/**/__init__.py", # Omit init files
"src/**/__main__.py", # Omit main files if they are just entry points
"tools/**/__init__.py", # Omit init files in tools
"**/modules/example/**", # Optional example module (not in repo); avoids "No source for code" if stale
# Add other specific files/patterns to omit for specfact-cli
]
[tool.coverage.paths]
source = [
"src/",
"*/site-packages/",
"tools/"
]
[tool.coverage.report]
# Treat missing source (e.g. removed/optional modules like example) as warning, do not fail
ignore_errors = true
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"raise NotImplementedError",
"if __name__ == '__main__':",
"if TYPE_CHECKING:",
"pass",
"raise AssertionError",
"@abstractmethod",
"except ImportError:", # Often used for optional imports
"except Exception:", # Too broad, consider more specific exceptions
]
show_missing = true
# Contract-first approach: Line coverage is advisory; thresholds are enforced by contract-first layers in CI.
# Lower threshold (50%) recognizes that contracts provide runtime validation at API boundaries.
# Focus on contract coverage (80%+) and scenario tests for comprehensive validation.
fail_under = 50 # 50% line coverage for unit tests (contract-first: contracts provide primary validation)
[tool.coverage.html]
directory = "logs/tests/coverage/html"
[tool.coverage.xml]
output = "logs/tests/coverage/coverage.xml"
[tool.pytest-asyncio] # Add if you use asyncio tests
mode = "strict"
default_fixture_loop_scope = "function"
[tool.pytest-timeout]
timeout = 30
method = "thread"
[tool.hatch.build]
dev-mode-dirs = ["src","tools"]
[tool.hatch.build.targets.wheel]
only-include = [
"src/specfact_cli",
]
sources = ["src"]
[tool.hatch.build.targets.wheel.force-include]
"resources/templates" = "specfact_cli/resources/templates"
"resources/schemas" = "specfact_cli/resources/schemas"
"resources/mappings" = "specfact_cli/resources/mappings"
"resources/keys" = "specfact_cli/resources/keys"
"modules/bundle-mapper" = "specfact_cli/modules/bundle-mapper"
# Note: resources/semgrep files are in src/specfact_cli/resources/semgrep/ and are automatically included
[tool.hatch.build.targets.sdist]
# Only include essential files in source distribution
include = [
"/src",
"/resources",
"/README.md",
"/LICENSE",
"/pyproject.toml",
]
# Exclude development files, tests, docs, tools, etc.
exclude = [
"/.git",
"/.github",
"/.cursor",
"/.specfact",
"/tests",
"/tools",
"/docs",
"/contracts",
"/reports",
"/logs",
"/dist",
"/build",
"/.pytest_cache",
"/.coverage",
"/.coverage.*",
"/coverage.xml",
"/htmlcov",
"/__pycache__",
"/*.pyc",
"/*.pyo",
"/*.pyd",
"/.Python",
"/.env",
"/.venv",
"/venv",
"/env",
"/.mypy_cache",
"/.ruff_cache",
"/.pylint.d",
"/.cache",
"/.tox",
"/.eggs",
"/*.egg-info",
"/.DS_Store",
"/.vscode",
"/.idea",
"/*.code-workspace",
"/.cursorrules",
"/.prettierrc.json",
"/.yamllint",
"/pyrightconfig.json",
"/setup.py",
"/AGENTS.md",
"/CHANGELOG.md",
"/CLA.md",
"/CODE_OF_CONDUCT.md",
"/CONTRIBUTING.md",
"/SECURITY.md",
"/USAGE-FAQ.md",
]
# [tool.hatch.envs.default.env-vars] # Add if you have default env vars for hatch environments
# MY_VAR = "value"
[tool.isort]
profile = "ruff"
multi_line_output = 3
line_length = 120 # From your original config
[tool.basedpyright]
pythonVersion = "3.12"
typeCheckingMode = "strict"
useLibraryCodeForTypes = true
reportMissingImports = true
reportMissingTypeStubs = false
reportImportCycles = false
reportUnusedImport = true
reportUnusedClass = true
reportUnusedFunction = true
reportUnusedVariable = true
reportDuplicateImport = true
reportOptionalSubscript = true
reportOptionalMemberAccess = true
reportOptionalCall = true
reportOptionalIterable = true
reportOptionalContextManager = true
reportOptionalOperand = true
reportUntypedFunctionDecorator = true
reportUntypedClassDecorator = true
reportUntypedBaseClass = true
reportUntypedNamedTuple = true
reportPrivateUsage = true
reportConstantRedefinition = true
reportIncompatibleMethodOverride = true
reportIncompatibleVariableOverride = true
reportOverlappingOverloads = true
reportUninitializedInstanceVariable = true
reportInvalidStringEscapeSequence = true
reportUnknownParameterType = true
reportUnknownArgumentType = true
reportUnknownLambdaType = true
reportUnknownVariableType = true
reportUnknownMemberType = true
reportMissingParameterType = true
reportMissingTypeArgument = true
reportInvalidTypeVarUse = true
reportCallInDefaultInitializer = true
reportUnnecessaryIsInstance = true
reportUnnecessaryCast = true
reportAssertAlwaysTrue = true
reportSelfClsParameterName = true
reportImplicitStringConcatenation = true
reportUnboundVariable = true
reportUndefinedVariable = true
[tool.basedpyright.reportUnnecessaryComparison]
enabled = true
[tool.basedpyright.reportUnnecessaryContains]
enabled = true
[tool.basedpyright.reportUnnecessaryTypeIgnoreComment]
enabled = true
[tool.basedpyright.reportImplicitOverride]
enabled = true
[tool.basedpyright.reportShadowedImports]
enabled = true
# Module-specific overrides
[[tool.basedpyright.override]]
module = [
"numpy.*",
"pandas.*",
"matplotlib.*"
]
reportMissingImports = false
[[tool.basedpyright.override]]
module = [
"markdown.*",
"redis.*",
"dotenv.*",
"github.*",
"pytest.*",
"setuptools.*"
]
reportMissingImports = false
[[tool.basedpyright.override]]
module = [
"src.specfact_cli.common.*",
"tools.*"
]
typeCheckingMode = "basic"
[[tool.basedpyright.override]]
module = [
"specfact_cli.telemetry"
]
reportMissingImports = false
[tool.pytest.ini_options]
minversion = "8.4.2"
addopts = "-ra -v --import-mode=importlib" # Combined and no coverage flags
pythonpath = [
"src",
"tools"
]
testpaths = [
"tests",
# "../src" # pythonpath = ["src"] should cover imports from src for tests in /tests
]
# Note: TEST_MODE is set in tests/conftest.py to skip Semgrep in tests
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
markers = [
"asyncio: mark test as async",
"integration: marks tests as integration tests",
"timeout: mark tests with a timeout",
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"workflow_coverage: mark test for workflow coverage tracking",
"component_coverage: mark test for component coverage tracking",
"contract_coverage: mark test for contract coverage tracking",
"state_transition_coverage: mark test for state transition coverage tracking",
]
filterwarnings = [ # From pytest.ini
"ignore::UserWarning:rich.live", # Filter Rich library warnings about ipywidgets (not needed for CLI tests)
"ignore::pytest.PytestAssertRewriteWarning",
"ignore::pytest.PytestDeprecationWarning",
]
log_cli = true # From pytest.ini
log_cli_level = "INFO" # From pytest.ini
[tool.pylint.messages_control]
disable = [
"C0114", # missing-module-docstring
"C0115", # missing-class-docstring
"C0116", # missing-function-docstring
"C0103", # invalid-name (too restrictive for some cases)
# C0330, C0326 removed in pylint 3.x (handled by ruff format)
"R0903", # too-few-public-methods
"R0913", # too-many-arguments (too restrictive for APIs)
"R0912", # too-many-branches
"R0915", # too-many-statements
"W0511", # fixme
"C0413", # wrong-import-position (handled by isort)
"E0401", # unable-to-import (false positives for local modules in pylint)
"E0611", # no-name-in-module (false positives for local modules in pylint)
"E1101", # no-member (false positives for Pydantic/FieldInfo, rich.Progress.tasks)
"E0601", # used-before-assignment (false positives in try/except UTC, tomllib)
"E1126", # invalid-sequence-index (rich TaskID)
"E0603", # undefined-all-variable
"E1136", # unsubscriptable-object
"E0110", # abstract-class-instantiated
]
[tool.pylint.master]
# Allow pylint to analyze tools directory and src directory
init-hook = """
import sys
import os
sys.path.insert(0, 'tools')
sys.path.insert(0, os.path.join(os.getcwd(), 'src'))
"""
[tool.pylint.format]
max-line-length = 120
[tool.pylint.reports]
output-format = "parseable"
reports = "no"
[tool.pylint.design]
max-args = 8 # Allow reasonable number of arguments
max-locals = 20 # Allow reasonable number of local variables
max-returns = 8 # Allow reasonable number of return statements
max-branches = 15 # Allow reasonable number of branches
max-statements = 60 # Allow reasonable number of statements
max-parents = 8 # Allow reasonable inheritance depth
max-attributes = 12 # Allow reasonable number of attributes
[tool.pylint.similarities]
min-similarity-lines = 6 # Minimum lines for similarity check
ignore-comments = "yes"
ignore-docstrings = "yes"
ignore-imports = "yes"
[tool.ruff]
line-length = 120
target-version = "py312"
[tool.ruff.lint]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default, complementing pylint
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # Pyflakes
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"T10", # flake8-debugger
"T20", # flake8-print
"SIM", # flake8-simplify
"PIE", # flake8-pie
"RET", # flake8-return
"RUF", # Ruff-specific rules
]
ignore = [
"E501", # line too long (handled by ruff format)
"C901", # too complex (leave to pylint for governance)
"PLR0913", # too many arguments (pylint handles this better)
"PLR0912", # too many branches (pylint handles this better)
"PLR0915", # too many statements (pylint handles this better)
"PLR2004", # magic value comparison (too restrictive)
"PLR0911", # too many return statements (too restrictive)
"PLR0917", # too many positional arguments (too restrictive)
"FBT001", # boolean positional arg in function definition (too restrictive)
"FBT002", # boolean default positional argument (too restrictive)
"FBT003", # boolean positional value in function call (too restrictive)
"A003", # class attribute shadows a python builtin (too restrictive)
"S101", # assert used (too restrictive for tests)
"T20", # print found (too restrictive)
"BLE001", # do not catch blind exception (too restrictive)
"EM101", # exception must not use a string literal (too restrictive)
"EM102", # exception must not use an f-string literal (too restrictive)
"TRY003", # avoid specifying long messages outside exception class (too restrictive)
"ERA001", # found commented-out code (too restrictive)
"PD", # pandas-vet (not relevant)
"NPY", # NumPy-specific rules (not relevant)
"AIR", # airflow (not relevant)
"PERF", # perflint (not relevant)
"LOG", # flake8-logging (pylint handles logging better)
"G", # flake8-logging-format (pylint handles logging better)
"INP", # flake8-no-pep420 (too restrictive)
"SLF", # flake8-self (too restrictive)
"SLOT", # flake8-slots (too restrictive)
"TCH", # flake8-type-checking (too restrictive)
"INT", # flake8-gettext (not relevant)
"PYI", # flake8-pyi (not relevant)
"RUF012", # mutable class attributes should be annotated with ClassVar (too restrictive)
"RUF001", # flake8-ruff ambiguous unicode character (e.g. emoticons in strings)
]
[tool.ruff.lint.per-file-ignores]
# Tests can be more lenient
"tests/**/*" = [
"S101", # assert used
"PLR2004", # magic value comparison
"T20", # print found
"SLF001", # private member accessed
]
"tests/unit/tools/test_smart_test_coverage.py" = [
"E402", # imports after sys.path bootstrap for tool harness loading
]
"tests/unit/tools/test_smart_test_coverage_enhanced.py" = [
"E402", # imports after sys.path bootstrap for tool harness loading
]
# Tools and scripts can be more lenient
"tools/**/*" = [
"T20", # print found
"S101", # assert used
"INP001", # implicit namespace package
"PLR2004", # magic value comparison (acceptable in tools)
]
# Typer command files - B008 is acceptable for typer.Option/Argument patterns
"src/specfact_cli/commands/**/*" = [
"B008", # typer.Option/Argument in defaults (common Typer pattern)
]
"src/specfact_cli/modules/**/src/commands.py" = [
"B008", # typer.Option/Argument in defaults (common Typer pattern)
]
# shellingham must be patched before Typer imports it; remaining imports follow the try/except.
"src/specfact_cli/cli.py" = [
"E402",
]
[tool.ruff.lint.isort]
# Match isort ruff profile configuration
# Ruff-compatible: multi_line_output = 3, combine_as_imports = true
force-single-line = false
force-wrap-aliases = false
combine-as-imports = true
split-on-trailing-comma = true
lines-after-imports = 2
known-first-party = ["specfact_cli"]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
# Add this if you plan to use hatch version command
[tool.hatch.version]
path = "src/__init__.py"
# Add build hook configuration if needed, for example:
# [tool.hatch.build.hooks.custom]
# path = "hatch_hooks.py" # A custom script for build hooks
# Contract-First Development Configuration
[tool.icontract]
enable = true
violation_module = "common.contract_violations"
violation_handler = "common.contract_violations:handle_contract_violation"
include_origin = true
include_contracts = true
[tool.beartype]
enable = true
conflict_strategy = "first"
violation_door_type = "exception"
violation_verbosity = "verbose"
[tool.crosshair]
timeout = 60
per_condition_timeout = 10
per_path_timeout = 5
max_iterations = 1000
# Contract-First Coverage Metrics
[tool.contract_coverage]
# Contract coverage measures behavioral coverage, not line coverage
# This is separate from traditional unit test line coverage
fail_under = 80 # 80% of public APIs should have contracts
contract_coverage_threshold = 80
behavioral_coverage_threshold = 90