impactguard 0.1.0__py3-none-any.whl

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,164 @@
1
+ from typing import Any
2
+
3
+ """
4
+ ImpactGuard - Lightweight API impact analyzer for Python projects.
5
+
6
+ Track function signatures, detect breaking changes, and analyze call-site impact
7
+ using static and runtime techniques.
8
+ """
9
+ from .analyze_module import analyze as analyze_module, analyze_calls
10
+ from .compare_signatures import compare, load
11
+ from .enforce_gate import enforce, enforce_report
12
+ from .extract_signatures import extract, serialize_function
13
+ from .generate_report import generate_html, generate_html_from_file
14
+ from .impact_analysis import analyze, build_call_graph, find_transitive_callers
15
+ from .patch_confidence import (
16
+ classify as classify_patch,
17
+ classify_with_factors,
18
+ )
19
+ from .patch_confidence import (
20
+ compute_confidence,
21
+ get_complexity_penalty,
22
+ get_semantic_risk,
23
+ get_structural_safety,
24
+ get_target_certainty,
25
+ )
26
+ from .cst_patch import patch_function, patch_call
27
+ from .suggest_fixes import suggest, enrich_with_fixes, get_line
28
+ from .trace_calls import trace, install_tracer, dump as dump_trace
29
+ from .trace_calls_prod import (
30
+ flush,
31
+ should_sample,
32
+ install_tracer as install_tracer_prod,
33
+ )
34
+ from .risk_model import (
35
+ SEVERITY_SCORES,
36
+ classify,
37
+ compute_risk,
38
+ confidence,
39
+ exposure,
40
+ get_severity,
41
+ )
42
+ from .pipeline import (
43
+ run_pipeline,
44
+ quick_check,
45
+ run_pipeline_git,
46
+ ImpactGuard,
47
+ )
48
+ from .config import get_config, load_config, reload_config, get as get_config_value
49
+ from .semver import suggest_semver, format_semver_recommendation
50
+ from .baseline import (
51
+ save_baseline,
52
+ load_baseline,
53
+ compare_with_baseline,
54
+ baseline_exists,
55
+ )
56
+
57
+ __version__ = "0.1.0"
58
+ __all__ = [
59
+ # Signature extraction
60
+ "extract",
61
+ "serialize_function",
62
+ # Comparison
63
+ "compare",
64
+ "load",
65
+ # Impact analysis
66
+ "analyze",
67
+ "analyze_module",
68
+ "analyze_calls",
69
+ "build_call_graph",
70
+ "find_transitive_callers",
71
+ # Risk model
72
+ "SEVERITY_SCORES",
73
+ "get_severity",
74
+ "exposure",
75
+ "confidence",
76
+ "classify",
77
+ "compute_risk",
78
+ # Patch confidence
79
+ "compute_confidence",
80
+ "classify_patch",
81
+ "classify_with_factors",
82
+ "get_target_certainty",
83
+ "get_structural_safety",
84
+ "get_semantic_risk",
85
+ "get_complexity_penalty",
86
+ # Reporting
87
+ "generate_html",
88
+ "generate_html_from_file",
89
+ "enforce",
90
+ "enforce_report",
91
+ # CST patches
92
+ "patch_function",
93
+ "patch_call",
94
+ # Suggest fixes
95
+ "suggest",
96
+ "enrich_with_fixes",
97
+ "get_line",
98
+ # Runtime tracing
99
+ "trace",
100
+ "install_tracer",
101
+ "dump_trace",
102
+ "flush",
103
+ "should_sample",
104
+ "install_tracer_prod",
105
+ # Pipeline (Recommended)
106
+ "run_pipeline",
107
+ "quick_check",
108
+ "run_pipeline_git",
109
+ "ImpactGuard",
110
+ # Config
111
+ "get_config",
112
+ "load_config",
113
+ "reload_config",
114
+ "get_config_value",
115
+ # Semver
116
+ "suggest_semver",
117
+ "format_semver_recommendation",
118
+ # Baseline
119
+ "save_baseline",
120
+ "load_baseline",
121
+ "compare_with_baseline",
122
+ "baseline_exists",
123
+ ]
124
+
125
+
126
+ def extract_signatures(files: list[str]) -> list[dict[str, Any]]:
127
+ """Extract function signatures from Python files.
128
+
129
+ Args:
130
+ files: List of Python file paths.
131
+
132
+ Returns:
133
+ List of signature dictionaries.
134
+ """
135
+ return extract(files)
136
+
137
+
138
+ def compare_signatures(old_path: str, new_path: str) -> dict[str, list[str]]:
139
+ """Compare two signature snapshots.
140
+
141
+ Args:
142
+ old_path: Path to old signatures JSON.
143
+ new_path: Path to new signatures JSON.
144
+
145
+ Returns:
146
+ Dictionary with 'breaking' and 'nonbreaking' lists.
147
+ """
148
+ return compare(old_path, new_path)
149
+
150
+
151
+ def analyze_impact(
152
+ sigs_path: str, calls_path: str, runtime_path: str | None = None
153
+ ) -> list[dict[str, Any]]:
154
+ """Analyze impact of signature changes on call sites.
155
+
156
+ Args:
157
+ sigs_path: Path to signatures JSON file.
158
+ calls_path: Path to calls JSON file.
159
+ runtime_path: Optional path to runtime data JSON.
160
+
161
+ Returns:
162
+ List of impact issues.
163
+ """
164
+ return analyze(sigs_path, calls_path, runtime_path)