gitnexus 1.6.2-rc.20 → 1.6.2-rc.21
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.
|
@@ -19,6 +19,20 @@ export const pythonImportStrategy = (rawImportPath, filePath, ctx) => {
|
|
|
19
19
|
// PEP 328: unresolved relative imports should not fall through to suffix matching
|
|
20
20
|
if (rawImportPath.startsWith('.'))
|
|
21
21
|
return { kind: 'files', files: [] };
|
|
22
|
+
// External dotted imports like `django.apps` should not fall through to generic
|
|
23
|
+
// suffix matching when the repo has unrelated local files such as `accounts/apps.py`.
|
|
24
|
+
// Keep suffix fallback only when the leading segment appears somewhere in-repo,
|
|
25
|
+
// which preserves existing internal absolute-import behavior like `accounts.models`.
|
|
26
|
+
const pathLike = rawImportPath.replace(/\./g, '/');
|
|
27
|
+
if (pathLike.includes('/')) {
|
|
28
|
+
const [leadingSegment] = pathLike.split('/').filter(Boolean);
|
|
29
|
+
const hasRepoCandidate = !!leadingSegment &&
|
|
30
|
+
(ctx.index.get(`${leadingSegment}.py`) !== undefined ||
|
|
31
|
+
ctx.index.get(`${leadingSegment}/__init__.py`) !== undefined ||
|
|
32
|
+
ctx.index.getFilesInDir(leadingSegment, '.py').length > 0);
|
|
33
|
+
if (!hasRepoCandidate)
|
|
34
|
+
return { kind: 'files', files: [] };
|
|
35
|
+
}
|
|
22
36
|
return null;
|
|
23
37
|
};
|
|
24
38
|
export const pythonImportConfig = {
|
package/package.json
CHANGED