diff --git a/lib/spack/spack/cmd/modules/lmod.py b/lib/spack/spack/cmd/modules/lmod.py index 4fd6992a47a..3f2f7d2ec04 100644 --- a/lib/spack/spack/cmd/modules/lmod.py +++ b/lib/spack/spack/cmd/modules/lmod.py @@ -8,6 +8,7 @@ import spack.cmd.common.arguments import spack.cmd.modules import spack.config +import spack.modules import spack.modules.lmod diff --git a/lib/spack/spack/cmd/modules/tcl.py b/lib/spack/spack/cmd/modules/tcl.py index 4ca8ece7044..e31d5bcc46f 100644 --- a/lib/spack/spack/cmd/modules/tcl.py +++ b/lib/spack/spack/cmd/modules/tcl.py @@ -7,6 +7,7 @@ import spack.cmd.common.arguments import spack.cmd.modules import spack.config +import spack.modules import spack.modules.tcl diff --git a/lib/spack/spack/cmd/style.py b/lib/spack/spack/cmd/style.py index 5925d1120e5..9d164875ae2 100644 --- a/lib/spack/spack/cmd/style.py +++ b/lib/spack/spack/cmd/style.py @@ -15,6 +15,7 @@ from llnl.util.filesystem import working_dir import spack.paths +import spack.repo import spack.util.git from spack.util.executable import Executable, which @@ -38,7 +39,7 @@ def grouper(iterable, n, fillvalue=None): #: double-check the results of other tools (if, e.g., --fix was provided) #: The list maps an executable name to a method to ensure the tool is #: bootstrapped or present in the environment. -tool_names = ["import-check", "isort", "black", "flake8", "mypy"] +tool_names = ["import", "isort", "black", "flake8", "mypy"] #: warnings to ignore in mypy mypy_ignores = [ @@ -370,10 +371,19 @@ def run_black(black_cmd, file_list, args): def _module_part(root: str, expr: str): parts = expr.split(".") + # spack.pkg is for repositories, don't try to resolve it here. + if ".".join(parts[:2]) == spack.repo.ROOT_PYTHON_NAMESPACE: + return None while parts: f1 = os.path.join(root, "lib", "spack", *parts) + ".py" f2 = os.path.join(root, "lib", "spack", *parts, "__init__.py") - if os.path.exists(f1) or os.path.exists(f2): + + if ( + os.path.exists(f1) + # ensure case sensitive match + and f"{parts[-1]}.py" in os.listdir(os.path.dirname(f1)) + or os.path.exists(f2) + ): return ".".join(parts) parts.pop() return None @@ -389,7 +399,7 @@ def _run_import_check( out=sys.stdout, ): if sys.version_info < (3, 9): - print("import-check requires Python 3.9 or later") + print("import check requires Python 3.9 or later") return 0 is_use = re.compile(r"(?