diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-08-31 12:17:39 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-08-31 12:35:31 +0200 |
commit | 86196afd3f90e0df2a3ee5c86977abffba6c5cfa (patch) | |
tree | 6fe6b5fb29d10fec1ce9ff102f1269312b95cad4 /bin | |
parent | 489a2f9b830f37d9bbf87f65701cf3b96681af5e (diff) | |
download | justbuild-86196afd3f90e0df2a3ee5c86977abffba6c5cfa.tar.gz |
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.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/just-import-git.py | 14 |
1 files changed, 5 insertions, 9 deletions
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( |