We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 33ef2aa commit 8ce0f3fCopy full SHA for 8ce0f3f
src/access_py_telemetry/ast.py
@@ -5,6 +5,7 @@
5
6
from typing import Any
7
import ast
8
+import re
9
from IPython.core.getipython import get_ipython
10
from IPython.core.interactiveshell import ExecutionInfo
11
@@ -17,6 +18,8 @@
17
18
19
registries = {registry: TelemetryRegister(registry) for registry in REGISTRIES.keys()}
20
21
+IPYTHON_MAGIC_PATTERN = r"^\s*[%!?]{1,2}"
22
+
23
24
def capture_registered_calls(info: ExecutionInfo) -> None:
25
"""
@@ -39,7 +42,7 @@ def capture_registered_calls(info: ExecutionInfo) -> None:
39
42
40
43
# Remove lines that contain IPython magic commands
41
44
code = "\n".join(
- line for line in code.splitlines() if not line.strip().startswith("%")
45
+ line for line in code.splitlines() if not re.match(IPYTHON_MAGIC_PATTERN, line)
46
)
47
48
tree = ast.parse(code)
0 commit comments