@@ -280,7 +280,12 @@ def match_parent_module(package_name: str, module_names: Iterable[str]) -> Optio
280280
281281
282282@tracer .start_as_current_span ("resolve_gomod" )
283- def resolve_gomod (app_source_path , request , dep_replacements = None , git_dir_path = None ):
283+ def resolve_gomod (
284+ app_source_path : Path ,
285+ request : dict [str , Any ],
286+ dep_replacements : Optional [list [dict [str , str ]]] = None ,
287+ git_dir_path : Optional [Path ] = None ,
288+ ) -> dict [str , Any ]:
284289 """
285290 Resolve and fetch gomod dependencies for given app source archive.
286291
@@ -455,10 +460,10 @@ def go_list_deps(pattern: Literal["./...", "all"]) -> Iterator[GoPackage]:
455460 main_packages .append ({"pkg" : main_pkg , "pkg_deps" : pkg_deps })
456461
457462 _vet_local_deps (main_module_deps , main_module_name , app_source_path , git_dir_path )
458- for pkg in main_packages :
463+ for package in main_packages :
459464 # Local dependencies are always relative to the main module, even for subpackages
460- _vet_local_deps (pkg ["pkg_deps" ], main_module_name , app_source_path , git_dir_path )
461- _set_full_local_dep_relpaths (pkg ["pkg_deps" ], main_module_deps )
465+ _vet_local_deps (package ["pkg_deps" ], main_module_name , app_source_path , git_dir_path )
466+ _set_full_local_dep_relpaths (package ["pkg_deps" ], main_module_deps )
462467
463468 return {
464469 "module" : main_module ,
@@ -503,7 +508,7 @@ def _get_name_and_version(module: GoModule) -> tuple[str, str]:
503508 return name , version
504509
505510
506- def _should_vendor_deps (flags : List [str ], app_dir : str , strict : bool ) -> Tuple [bool , bool ]:
511+ def _should_vendor_deps (flags : List [str ], app_dir : Path , strict : bool ) -> Tuple [bool , bool ]:
507512 """
508513 Determine if Cachito should vendor dependencies and if it is allowed to make changes.
509514
@@ -517,7 +522,7 @@ def _should_vendor_deps(flags: List[str], app_dir: str, strict: bool) -> Tuple[b
517522 :return: (should vendor: bool, allowed to make changes in the vendor directory: bool)
518523 :raise ValidationError: if the vendor dir is present, the flags are not used and we are strict
519524 """
520- vendor = Path ( app_dir ) / "vendor"
525+ vendor = app_dir / "vendor"
521526
522527 if "gomod-vendor-check" in flags :
523528 return True , not vendor .exists ()
@@ -534,7 +539,7 @@ def _should_vendor_deps(flags: List[str], app_dir: str, strict: bool) -> Tuple[b
534539
535540
536541@tracer .start_as_current_span ("_vendor_deps" )
537- def _vendor_deps (go : Go , run_params : dict , can_make_changes : bool , git_dir : str ) -> list [GoModule ]:
542+ def _vendor_deps (go : Go , run_params : dict , can_make_changes : bool , git_dir : Path ) -> list [GoModule ]:
538543 """
539544 Vendor golang dependencies.
540545
@@ -609,7 +614,7 @@ def parse_module_line(line: str) -> GoModule:
609614
610615
611616@tracer .start_as_current_span ("_vendor_changed" )
612- def _vendor_changed (git_dir : str , app_dir : str ) -> bool :
617+ def _vendor_changed (git_dir : Path , app_dir : str ) -> bool :
613618 """Check for changes in the vendor directory."""
614619 vendor = Path (app_dir ).relative_to (git_dir ).joinpath ("vendor" )
615620 modules_txt = vendor / "modules.txt"
@@ -640,7 +645,7 @@ def _vet_local_deps(
640645 dependencies : List [dict ],
641646 module_name : str ,
642647 app_source_path : Path ,
643- git_dir_path : str ,
648+ git_dir_path : Path ,
644649) -> None :
645650 """Fail if any local file dependency path is either absolute or outside the repository."""
646651 for dep in dependencies :
@@ -666,19 +671,19 @@ def _vet_local_deps(
666671
667672
668673def _validate_local_dependency_path (
669- app_source_path : Path , git_dir_path : str , dep_path : str
674+ app_source_path : Path , git_dir_path : Path , dep_path : str
670675) -> None :
671676 """
672677 Validate that the local dependency path is not outside the repository.
673678
674679 :param Path app_source_path: the full path to the application source code
675- :param str git_dir_path: the full path to the git repository
680+ :param Path git_dir_path: the full path to the git repository
676681 :param str dep_path: the relative path for local replacements (the dep version)
677682 :raise ValidationError: if the local dependency path is invalid
678683 """
679684 try :
680685 resolved_dep_path = Path (app_source_path , dep_path ).resolve ()
681- resolved_dep_path .relative_to (Path ( git_dir_path ) .resolve ())
686+ resolved_dep_path .relative_to (git_dir_path .resolve ())
682687 except ValueError :
683688 raise ValidationError (f"The local dependency path { dep_path } is outside the repository" )
684689
0 commit comments