@@ -62,10 +62,20 @@ class StrEnum(str, Enum):
6262)
6363
6464
65- class FastDevCliError (Exception ): ...
65+ class FastDevCliError (Exception ):
66+ """Basic exception of this library, all custom exceptions inherit from it"""
6667
6768
68- class ShellCommandError (FastDevCliError ): ...
69+ class ShellCommandError (FastDevCliError ):
70+ """Raise if cmd command returncode is not zero"""
71+
72+
73+ class ParseError (FastDevCliError ):
74+ """Raise this if parse dependence line error"""
75+
76+
77+ class EnvError (FastDevCliError ):
78+ """Raise when expected to be managed by poetry, but toml file not found."""
6979
7080
7181def poetry_module_name (name : str ) -> str :
@@ -536,10 +546,6 @@ def bump() -> None:
536546 return BumpUp (commit , part , no_sync = "--no-sync" in args , dry = "--dry" in args ).run ()
537547
538548
539- class EnvError (Exception ):
540- """Raise when expected to be managed by poetry, but toml file not found."""
541-
542-
543549class Project :
544550 path_depth = 5
545551 _tool : ToolName | None = None
@@ -591,30 +597,33 @@ def get_manage_tool(cls: type[Self], cache: bool = False) -> ToolName | None:
591597 try :
592598 text = cls .load_toml_text ()
593599 except EnvError :
594- pass
595- else :
596- with contextlib .suppress (KeyError , tomllib .TOMLDecodeError ):
597- doc = tomllib .loads (text )
598- backend = doc ["build-system" ]["build-backend" ]
599- if "poetry" in backend :
600- cls ._tool = "poetry"
601- return cls ._tool
602- elif "pdm" in backend :
603- cls ._tool = "pdm"
604- work_dir = cls .get_work_dir (allow_cwd = True )
605- if not Path (work_dir , "pdm.lock" ).exists () and (
606- "[tool.uv]" in text or Path (work_dir , "uv.lock" ).exists ()
607- ):
608- cls ._tool = "uv"
609- return cls ._tool
610- for name in get_args (ToolName ):
611- if f"[tool.{ name } ]" in text :
612- cls ._tool = cast (ToolName , name )
613- return cls ._tool
614- # Poetry 2.0 default to not include the '[tool.poetry]' section
615- if cls .is_poetry_v2 (text ):
600+ return None
601+ with contextlib .suppress (KeyError , tomllib .TOMLDecodeError ):
602+ doc = tomllib .loads (text )
603+ backend = doc ["build-system" ]["build-backend" ]
604+ if "poetry" in backend :
616605 cls ._tool = "poetry"
617606 return cls ._tool
607+ work_dir = cls .get_work_dir (allow_cwd = True )
608+ uv_lock_exists = Path (work_dir , "uv.lock" ).exists ()
609+ if "pdm" in backend :
610+ cls ._tool = "pdm"
611+ if not Path (work_dir , "pdm.lock" ).exists () and (
612+ uv_lock_exists or "[tool.uv]" in text
613+ ):
614+ cls ._tool = "uv"
615+ return cls ._tool
616+ elif uv_lock_exists :
617+ cls ._tool = "uv"
618+ return cls ._tool
619+ for name in get_args (ToolName ):
620+ if f"[tool.{ name } ]" in text :
621+ cls ._tool = cast (ToolName , name )
622+ return cls ._tool
623+ # Poetry 2.0 default to not include the '[tool.poetry]' section
624+ if cls .is_poetry_v2 (text ):
625+ cls ._tool = "poetry"
626+ return cls ._tool
618627 return None
619628
620629 @staticmethod
@@ -665,12 +674,6 @@ def sync_dependencies(cls, prod: bool = True) -> None:
665674 run_and_echo (cmd )
666675
667676
668- class ParseError (Exception ):
669- """Raise this if parse dependence line error"""
670-
671- pass
672-
673-
674677class UpgradeDependencies (Project , DryRun ):
675678 def __init__ (
676679 self , _exit : bool = False , dry : bool = False , tool : ToolName = "poetry"
@@ -1144,18 +1147,11 @@ def make_style(
11441147 bandit = _ensure_bool (bandit )
11451148 prefix = _ensure_bool (prefix )
11461149 tool = _ensure_str (tool )
1150+ kwargs = {"dry" : dry , "skip_mypy" : skip , "dmypy" : dmypy , "bandit" : bandit }
11471151 if _ensure_bool (check_only ):
1148- check (files , dry = dry , skip_mypy = skip , dmypy = dmypy , bandit = bandit , tool = tool )
1152+ check (files , tool = tool , ** kwargs )
11491153 else :
1150- lint (
1151- files ,
1152- dry = dry ,
1153- skip_mypy = skip ,
1154- dmypy = dmypy ,
1155- bandit = bandit ,
1156- tool = tool ,
1157- prefix = prefix ,
1158- )
1154+ lint (files , prefix = prefix , tool = tool , ** kwargs )
11591155
11601156
11611157@cli .command (name = "check" )
@@ -1508,8 +1504,7 @@ def common(
15081504 is_eager = True ,
15091505 help = "Show the version of this tool" ,
15101506 ),
1511- ) -> None :
1512- pass
1507+ ) -> None : ...
15131508
15141509
15151510def main () -> None :
0 commit comments