bubble-analysis 0.2.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.
- bubble/__init__.py +3 -0
- bubble/cache.py +207 -0
- bubble/cli.py +470 -0
- bubble/config.py +52 -0
- bubble/detectors.py +90 -0
- bubble/enums.py +65 -0
- bubble/extractor.py +829 -0
- bubble/formatters.py +887 -0
- bubble/integrations/__init__.py +92 -0
- bubble/integrations/base.py +98 -0
- bubble/integrations/cli_scripts/__init__.py +49 -0
- bubble/integrations/cli_scripts/cli.py +108 -0
- bubble/integrations/cli_scripts/detector.py +149 -0
- bubble/integrations/django/__init__.py +63 -0
- bubble/integrations/django/cli.py +111 -0
- bubble/integrations/django/detector.py +331 -0
- bubble/integrations/django/semantics.py +40 -0
- bubble/integrations/fastapi/__init__.py +57 -0
- bubble/integrations/fastapi/cli.py +110 -0
- bubble/integrations/fastapi/detector.py +176 -0
- bubble/integrations/fastapi/semantics.py +14 -0
- bubble/integrations/flask/__init__.py +57 -0
- bubble/integrations/flask/cli.py +110 -0
- bubble/integrations/flask/detector.py +191 -0
- bubble/integrations/flask/semantics.py +19 -0
- bubble/integrations/formatters.py +268 -0
- bubble/integrations/generic/__init__.py +13 -0
- bubble/integrations/generic/config.py +106 -0
- bubble/integrations/generic/detector.py +346 -0
- bubble/integrations/generic/frameworks.py +145 -0
- bubble/integrations/models.py +68 -0
- bubble/integrations/queries.py +481 -0
- bubble/loader.py +118 -0
- bubble/models.py +397 -0
- bubble/propagation.py +737 -0
- bubble/protocols.py +104 -0
- bubble/queries.py +627 -0
- bubble/results.py +211 -0
- bubble/stubs.py +89 -0
- bubble/timing.py +144 -0
- bubble_analysis-0.2.0.dist-info/METADATA +264 -0
- bubble_analysis-0.2.0.dist-info/RECORD +46 -0
- bubble_analysis-0.2.0.dist-info/WHEEL +5 -0
- bubble_analysis-0.2.0.dist-info/entry_points.txt +2 -0
- bubble_analysis-0.2.0.dist-info/licenses/LICENSE +21 -0
- bubble_analysis-0.2.0.dist-info/top_level.txt +1 -0
bubble/protocols.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""Detector protocol definitions for custom detectors.
|
|
2
|
+
|
|
3
|
+
These protocols define the interface that custom detectors must implement.
|
|
4
|
+
Claude (or humans) can implement these for project-specific patterns.
|
|
5
|
+
|
|
6
|
+
Example usage in .flow/detectors/entrypoints.py:
|
|
7
|
+
|
|
8
|
+
from bubble.protocols import EntrypointDetector
|
|
9
|
+
from bubble.models import Entrypoint
|
|
10
|
+
import libcst as cst
|
|
11
|
+
|
|
12
|
+
class CeleryTaskDetector(EntrypointDetector):
|
|
13
|
+
def detect(self, source: str, file_path: str) -> list[Entrypoint]:
|
|
14
|
+
# Detect @celery.task decorators
|
|
15
|
+
...
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from typing import Protocol
|
|
19
|
+
|
|
20
|
+
from bubble.integrations.base import Entrypoint, GlobalHandler
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class EntrypointDetector(Protocol):
|
|
24
|
+
"""Protocol for detecting entrypoints in source code.
|
|
25
|
+
|
|
26
|
+
Entrypoints are where external input enters the program:
|
|
27
|
+
- HTTP routes (Flask, FastAPI, Django)
|
|
28
|
+
- CLI commands (argparse, click, typer)
|
|
29
|
+
- Queue handlers (Celery, RQ, SQS)
|
|
30
|
+
- Scheduled jobs (cron, APScheduler)
|
|
31
|
+
- Test functions (pytest, unittest)
|
|
32
|
+
|
|
33
|
+
Built-in detectors handle Flask, FastAPI, and CLI scripts.
|
|
34
|
+
Implement this protocol for custom patterns.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def detect(self, source: str, file_path: str) -> list[Entrypoint]:
|
|
38
|
+
"""Detect entrypoints in a Python source file.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
source: The Python source code as a string.
|
|
42
|
+
file_path: The path to the file being analyzed.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
A list of detected Entrypoint objects.
|
|
46
|
+
|
|
47
|
+
Example implementation:
|
|
48
|
+
def detect(self, source: str, file_path: str) -> list[Entrypoint]:
|
|
49
|
+
module = cst.parse_module(source)
|
|
50
|
+
# Walk the AST looking for your pattern
|
|
51
|
+
# Return Entrypoint objects for each match
|
|
52
|
+
"""
|
|
53
|
+
...
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class GlobalHandlerDetector(Protocol):
|
|
57
|
+
"""Protocol for detecting global exception handlers.
|
|
58
|
+
|
|
59
|
+
Global handlers catch exceptions at the application level:
|
|
60
|
+
- Flask @app.errorhandler(ExceptionClass)
|
|
61
|
+
- FastAPI app.add_exception_handler(ExceptionClass, handler)
|
|
62
|
+
- Django middleware exception handling
|
|
63
|
+
- Custom error handling middleware
|
|
64
|
+
|
|
65
|
+
Built-in detectors handle Flask and FastAPI.
|
|
66
|
+
Implement this protocol for custom patterns.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
def detect(self, source: str, file_path: str) -> list[GlobalHandler]:
|
|
70
|
+
"""Detect global exception handlers in a Python source file.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
source: The Python source code as a string.
|
|
74
|
+
file_path: The path to the file being analyzed.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
A list of detected GlobalHandler objects.
|
|
78
|
+
"""
|
|
79
|
+
...
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class DependencyDetector(Protocol):
|
|
83
|
+
"""Protocol for detecting implicit dependencies.
|
|
84
|
+
|
|
85
|
+
Dependencies are functions that run before another function:
|
|
86
|
+
- FastAPI Depends(some_function)
|
|
87
|
+
- Decorators that call other functions
|
|
88
|
+
- Context managers in function signatures
|
|
89
|
+
|
|
90
|
+
These create implicit call edges that affect exception propagation.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
def detect(self, source: str, file_path: str) -> list[tuple[str, str, str]]:
|
|
94
|
+
"""Detect implicit dependencies in a Python source file.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
source: The Python source code as a string.
|
|
98
|
+
file_path: The path to the file being analyzed.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
A list of tuples: (dependent_function, dependency_function, kind)
|
|
102
|
+
where kind describes the dependency type (e.g., "fastapi_depends").
|
|
103
|
+
"""
|
|
104
|
+
...
|