contextl 1.2.29 → 1.2.31
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.
- package/package.json +1 -1
- package/python/impact_analysis.py +1 -1
- package/python/import_parser.py +24 -3
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ import re
|
|
|
23
23
|
|
|
24
24
|
# Heuristics for detecting test files by path/name
|
|
25
25
|
TEST_MARKERS = ("test", "spec", "__tests__", "__mocks__")
|
|
26
|
-
_TEST_PATTERN = re.compile(r'
|
|
26
|
+
_TEST_PATTERN = re.compile(r'(?<![a-z0-9])(?:' + '|'.join(re.escape(m) for m in TEST_MARKERS) + r')(?![a-z0-9])', re.IGNORECASE)
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
@dataclass
|
package/python/import_parser.py
CHANGED
|
@@ -130,10 +130,31 @@ def _ts_imports_python(root: "Node") -> list[str]:
|
|
|
130
130
|
# from pathlib import Path
|
|
131
131
|
# from . import utils
|
|
132
132
|
# from ..models import User
|
|
133
|
+
rel_import = None
|
|
133
134
|
for child in node.children:
|
|
134
|
-
if child.type
|
|
135
|
-
|
|
136
|
-
break
|
|
135
|
+
if child.type == "relative_import":
|
|
136
|
+
rel_import = child.text.decode("utf-8", errors="replace")
|
|
137
|
+
break
|
|
138
|
+
|
|
139
|
+
if rel_import and rel_import.replace(".", "") == "":
|
|
140
|
+
# Bare relative import like `.` or `..`
|
|
141
|
+
seen_import = False
|
|
142
|
+
for child in node.children:
|
|
143
|
+
if child.type == "import":
|
|
144
|
+
seen_import = True
|
|
145
|
+
elif seen_import:
|
|
146
|
+
if child.type == "dotted_name":
|
|
147
|
+
results.append(f"{rel_import}{child.text.decode('utf-8', errors='replace')}")
|
|
148
|
+
elif child.type == "aliased_import":
|
|
149
|
+
for sub in child.children:
|
|
150
|
+
if sub.type == "dotted_name":
|
|
151
|
+
results.append(f"{rel_import}{sub.text.decode('utf-8', errors='replace')}")
|
|
152
|
+
break
|
|
153
|
+
else:
|
|
154
|
+
for child in node.children:
|
|
155
|
+
if child.type in ("dotted_name", "relative_import"):
|
|
156
|
+
results.append(child.text.decode("utf-8", errors="replace"))
|
|
157
|
+
break # only the module name, not the imported symbols
|
|
137
158
|
|
|
138
159
|
for child in node.children:
|
|
139
160
|
visit(child)
|