contextl 1.2.47 → 1.2.48
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/import_parser.py +8 -2
package/package.json
CHANGED
package/python/import_parser.py
CHANGED
|
@@ -606,9 +606,15 @@ def _find_file_in_repo(
|
|
|
606
606
|
|
|
607
607
|
if matches:
|
|
608
608
|
if source_file:
|
|
609
|
-
|
|
609
|
+
def _sort_key(p):
|
|
610
|
+
is_init = 0 if p.endswith("__init__.py") else 1
|
|
611
|
+
if is_init == 0:
|
|
612
|
+
return (is_init, p.count("/"), _path_distance(source_file, p))
|
|
613
|
+
else:
|
|
614
|
+
return (is_init, _path_distance(source_file, p), p.count("/"))
|
|
615
|
+
matches.sort(key=_sort_key)
|
|
610
616
|
else:
|
|
611
|
-
matches.sort(key=lambda p: (
|
|
617
|
+
matches.sort(key=lambda p: (0 if p.endswith("__init__.py") else 1, p.count("/")))
|
|
612
618
|
return matches[0]
|
|
613
619
|
|
|
614
620
|
# Fallback for Python cross-language imports (e.g. from tests to .ts/.js core logic)
|