From 6af849b47392f36b6b9b78bc0de59d6b20eb1de8 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Wed, 18 Jun 2025 16:43:55 +0200 Subject: [PATCH 1/2] commands.py: Added some more return type hints Signed-off-by: Ole Herman Schumacher Elgesem --- cfbs/commands.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cfbs/commands.py b/cfbs/commands.py index 531df2ae..8fbd5780 100644 --- a/cfbs/commands.py +++ b/cfbs/commands.py @@ -562,7 +562,7 @@ def _someone_needs_me(this) -> bool: return 0 -def update_input_data(module, input_data): +def update_input_data(module, input_data) -> bool: """ Update input data from module definition @@ -666,7 +666,7 @@ def _update_variable(input_def, input_data): @cfbs_command("update") @commit_after_command("Updated module%s", [PLURAL_S]) -def update_command(to_update): +def update_command(to_update) -> Result: config = CFBSConfig.get_instance() config.warn_about_unknown_keys() build = config["build"] @@ -1074,7 +1074,7 @@ def analyze_command( user_ignored_path_components=None, offline=False, verbose=False, -): +) -> int: if len(policyset_paths) == 0: # no policyset path is a shorthand for using the current directory as the policyset path log.info( @@ -1138,7 +1138,7 @@ def analyze_command( @cfbs_command("input") @commit_after_command("Added input for module%s", [PLURAL_S]) -def input_command(args, input_from="cfbs input"): +def input_command(args, input_from="cfbs input") -> Result: config = CFBSConfig.get_instance() config.warn_about_unknown_keys() do_commit = False @@ -1256,7 +1256,7 @@ def _compare_list(a, b): @cfbs_command("get-input") -def get_input_command(name, outfile): +def get_input_command(name, outfile) -> int: config = CFBSConfig.get_instance() config.warn_about_unknown_keys() module = config.get_module_from_build(name) From 62f2daf7c54a15a65c67da1fb93210c44d59a198 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Wed, 18 Jun 2025 16:44:59 +0200 Subject: [PATCH 2/2] commands.py: Fixed return value of build_command This one would implicitly return None which does not match expectations nor the type hint. Now it returns whatever the actual build function returned. (Currently that function can only return 0, or exit / raise exceptions, but that might change). Signed-off-by: Ole Herman Schumacher Elgesem --- cfbs/commands.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cfbs/commands.py b/cfbs/commands.py index 8fbd5780..2ce8efb1 100644 --- a/cfbs/commands.py +++ b/cfbs/commands.py @@ -959,9 +959,12 @@ def build_command(ignore_versions=False) -> int: + "\nPlease see the error messages above and apply fixes accordingly." + "\nIf not fixed, these errors will cause your project to not build in future cfbs versions." ) + # We want the cfbs build command to be as backwards compatible as possible, + # so we try building anyway and don't return error(s) init_out_folder() _download_dependencies(config, prefer_offline=True, ignore_versions=ignore_versions) - perform_build_steps(config) + r = perform_build_steps(config) + return r @cfbs_command("install")