File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 5
5
6
6
from typing import Any
7
7
import ast
8
+ import re
8
9
from IPython .core .getipython import get_ipython
9
10
from IPython .core .interactiveshell import ExecutionInfo
10
11
17
18
18
19
registries = {registry : TelemetryRegister (registry ) for registry in REGISTRIES .keys ()}
19
20
21
+ IPYTHON_MAGIC_PATTERN = r"^\s*[%!?]{1,2}"
22
+
20
23
21
24
def capture_registered_calls (info : ExecutionInfo ) -> None :
22
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 (
42
- 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 )
43
46
)
44
47
45
48
tree = ast .parse (code )
You can’t perform that action at this time.
0 commit comments