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.
Files changed (46) hide show
  1. bubble/__init__.py +3 -0
  2. bubble/cache.py +207 -0
  3. bubble/cli.py +470 -0
  4. bubble/config.py +52 -0
  5. bubble/detectors.py +90 -0
  6. bubble/enums.py +65 -0
  7. bubble/extractor.py +829 -0
  8. bubble/formatters.py +887 -0
  9. bubble/integrations/__init__.py +92 -0
  10. bubble/integrations/base.py +98 -0
  11. bubble/integrations/cli_scripts/__init__.py +49 -0
  12. bubble/integrations/cli_scripts/cli.py +108 -0
  13. bubble/integrations/cli_scripts/detector.py +149 -0
  14. bubble/integrations/django/__init__.py +63 -0
  15. bubble/integrations/django/cli.py +111 -0
  16. bubble/integrations/django/detector.py +331 -0
  17. bubble/integrations/django/semantics.py +40 -0
  18. bubble/integrations/fastapi/__init__.py +57 -0
  19. bubble/integrations/fastapi/cli.py +110 -0
  20. bubble/integrations/fastapi/detector.py +176 -0
  21. bubble/integrations/fastapi/semantics.py +14 -0
  22. bubble/integrations/flask/__init__.py +57 -0
  23. bubble/integrations/flask/cli.py +110 -0
  24. bubble/integrations/flask/detector.py +191 -0
  25. bubble/integrations/flask/semantics.py +19 -0
  26. bubble/integrations/formatters.py +268 -0
  27. bubble/integrations/generic/__init__.py +13 -0
  28. bubble/integrations/generic/config.py +106 -0
  29. bubble/integrations/generic/detector.py +346 -0
  30. bubble/integrations/generic/frameworks.py +145 -0
  31. bubble/integrations/models.py +68 -0
  32. bubble/integrations/queries.py +481 -0
  33. bubble/loader.py +118 -0
  34. bubble/models.py +397 -0
  35. bubble/propagation.py +737 -0
  36. bubble/protocols.py +104 -0
  37. bubble/queries.py +627 -0
  38. bubble/results.py +211 -0
  39. bubble/stubs.py +89 -0
  40. bubble/timing.py +144 -0
  41. bubble_analysis-0.2.0.dist-info/METADATA +264 -0
  42. bubble_analysis-0.2.0.dist-info/RECORD +46 -0
  43. bubble_analysis-0.2.0.dist-info/WHEEL +5 -0
  44. bubble_analysis-0.2.0.dist-info/entry_points.txt +2 -0
  45. bubble_analysis-0.2.0.dist-info/licenses/LICENSE +21 -0
  46. 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
+ ...