Resolve native Python modules and packages before declared suffixes.
(candidate: Path)
| 3507 | |
| 3508 | |
| 3509 | def _probe_python_module_candidate(candidate: Path) -> Path | None: |
| 3510 | """Resolve native Python modules and packages before declared suffixes.""" |
| 3511 | if candidate.is_dir(): |
| 3512 | init_path = candidate / "__init__.py" |
| 3513 | if init_path.is_file() and effective_suffix(init_path) == ".py": |
| 3514 | return init_path |
| 3515 | if candidate.is_file(): |
| 3516 | return candidate |
| 3517 | if not candidate.name: |
| 3518 | return _probe_declared_python_module_candidate(candidate) |
| 3519 | py_candidate = candidate.with_suffix(".py") |
| 3520 | if py_candidate.is_file() and effective_suffix(py_candidate) == ".py": |
| 3521 | return py_candidate |
| 3522 | return _probe_declared_python_module_candidate(candidate) |
| 3523 | |
| 3524 | |
| 3525 | # Cache: scan root (resolved str) → dotted namespace prefix or "" |
no test coverage detected