From 86196afd3f90e0df2a3ee5c86977abffba6c5cfa Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 31 Aug 2023 12:17:39 +0200 Subject: just-import-git: fix fallout of type annotations In order to get the type checker happy, some wrong type annotations were added and, as a consequence, an unwarrented conditional as well. To make things worse, this as checking for the non-None-ness of a value by inspecting the truth value, ignoring that the non-None value "" also has truth value False. Remove this conditional alltogether and fix the type annotations. --- bin/just-import-git.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'bin/just-import-git.py') diff --git a/bin/just-import-git.py b/bin/just-import-git.py index 217e8dc3..f77efb8e 100755 --- a/bin/just-import-git.py +++ b/bin/just-import-git.py @@ -145,7 +145,7 @@ def clone(url: str, branch: str) -> Tuple[str, Dict[str, str], str]: return srcdir, repo, workdir -def get_repo_to_import(config: Json) -> Optional[str]: +def get_repo_to_import(config: Json) -> str: """From a given repository config, take the main repository.""" if config.get("main") is not None: return cast(str, config.get("main")) @@ -280,7 +280,6 @@ def handle_import(args: Namespace) -> Json: else: fail('Could not get repository config file') foreign_repos: Json = foreign_config.get("repositories", {}) - foreign_name: Optional[str] = None if args.foreign_repository_name: foreign_name = args.foreign_repository_name else: @@ -288,15 +287,12 @@ def handle_import(args: Namespace) -> Json: import_map: Json = {} for theirs, ours in args.import_map: import_map[theirs] = ours - main_repos: List[str] = [] - if (foreign_name): - main_repos = repos_to_import(foreign_repos, foreign_name, - import_map.keys()) + main_repos = repos_to_import(foreign_repos, foreign_name, + import_map.keys()) extra_repos = sorted([x for x in main_repos if x != foreign_name]) extra_imports = sorted(extra_layers_to_import(foreign_repos, main_repos)) - ordered_imports: List[str] = [cast(str, foreign_name) - ] + extra_repos + extra_imports - import_name = cast(str, foreign_name) + ordered_imports: List[str] = [foreign_name] + extra_repos + extra_imports + import_name = foreign_name if args.import_as is not None: import_name = args.import_as assign: Dict[str, str] = name_imports( -- cgit v1.2.3