55from pathlib import Path
66from typing import TYPE_CHECKING
77
8+ from typing_extensions import assert_never
9+
810from usethis ._config import usethis_config
9- from usethis ._config_file import (
10- DotImportLinterManager ,
11- )
11+ from usethis ._config_file import DotImportLinterManager
1212from usethis ._console import box_print , info_print , warn_print
1313from usethis ._integrations .ci .bitbucket .anchor import (
1414 ScriptItemAnchor as BitbucketScriptItemAnchor ,
1818from usethis ._integrations .file .ini .io_ import INIFileManager
1919from usethis ._integrations .file .pyproject_toml .io_ import PyprojectTOMLManager
2020from usethis ._integrations .file .setup_cfg .io_ import SetupCFGManager
21- from usethis ._integrations .pre_commit .schema import (
22- HookDefinition ,
23- Language ,
24- LocalRepo ,
25- )
21+ from usethis ._integrations .pre_commit .schema import HookDefinition , Language , LocalRepo
2622from usethis ._integrations .project .errors import ImportGraphBuildFailedError
2723from usethis ._integrations .project .imports import (
2824 LayeredArchitecture ,
2925 get_layered_architectures ,
3026)
3127from usethis ._integrations .project .name import get_project_name
3228from usethis ._integrations .project .packages import get_importable_packages
33- from usethis ._integrations .uv .deps import (
34- Dependency ,
35- )
29+ from usethis ._integrations .uv .deps import Dependency
3630from usethis ._integrations .uv .used import is_uv_used
3731from usethis ._tool .base import Tool
38- from usethis ._tool .config import (
39- ConfigEntry ,
40- ConfigItem ,
41- ConfigSpec ,
42- NoConfigValue ,
43- )
44- from usethis ._tool .impl .pre_commit import PreCommitTool
32+ from usethis ._tool .config import ConfigEntry , ConfigItem , ConfigSpec , NoConfigValue
4533from usethis ._tool .impl .ruff import RuffTool
4634from usethis ._tool .pre_commit import PreCommitConfig
4735from usethis ._tool .rule import RuleConfig
4836
4937if TYPE_CHECKING :
5038 from usethis ._io import KeyValueFileManager
51- from usethis ._tool .config import (
52- ResolutionT ,
53- )
39+ from usethis ._tool .config import ResolutionT
5440
5541
5642IMPORT_LINTER_CONTRACT_MIN_MODULE_COUNT = 3
@@ -77,7 +63,8 @@ def print_how_to_use(self) -> None:
7763 info_print (
7864 "For more info see <https://docs.python.org/3/tutorial/modules.html#packages>"
7965 )
80- if PreCommitTool ().is_used ():
66+ install_method = self .get_install_method ()
67+ if install_method == "pre-commit" :
8168 if is_uv_used ():
8269 box_print (
8370 f"Run 'uv run pre-commit run import-linter --all-files' to run { self .name } ."
@@ -86,10 +73,13 @@ def print_how_to_use(self) -> None:
8673 box_print (
8774 f"Run 'pre-commit run import-linter --all-files' to run { self .name } ."
8875 )
89- elif is_uv_used ():
90- box_print (f"Run 'uv run lint-imports' to run { self .name } ." )
76+ elif install_method == "devdep" or install_method is None :
77+ if is_uv_used ():
78+ box_print (f"Run 'uv run lint-imports' to run { self .name } ." )
79+ else :
80+ box_print (f"Run 'lint-imports' to run { self .name } ." )
9181 else :
92- box_print ( f"Run 'lint-imports' to run { self . name } ." )
82+ assert_never ( install_method )
9383
9484 def get_dev_deps (self , * , unconditional : bool = False ) -> list [Dependency ]:
9585 # We need to add the import-linter package itself as a dev dependency.
0 commit comments