From baf3ead650ea2750e0df6a7b5919088483dc6665 Mon Sep 17 00:00:00 2001 From: Paul McCarthy Date: Tue, 19 Apr 2022 16:00:12 +0100 Subject: [PATCH] style: exit early to reduce indentation --- cibuildwheel/macos.py | 30 ++++++++++++++++-------------- cibuildwheel/windows.py | 24 +++++++++++++----------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 71eea5e7..de6ee7ae 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -275,21 +275,23 @@ def build(options: Options, tmp_path: Path) -> None: options.globals.build_selector, options.globals.architectures ) - try: - if len(python_configurations) > 0: - before_all_options_identifier = python_configurations[0].identifier - before_all_options = options.build_options(before_all_options_identifier) + if len(python_configurations) == 0: + return - if before_all_options.before_all: - log.step("Running before_all...") - env = before_all_options.environment.as_dictionary(prev_environment=os.environ) - env.setdefault("MACOSX_DEPLOYMENT_TARGET", "10.9") - before_all_prepared = prepare_command( - before_all_options.before_all, - project=".", - package=before_all_options.package_dir, - ) - shell(before_all_prepared, env=env) + try: + before_all_options_identifier = python_configurations[0].identifier + before_all_options = options.build_options(before_all_options_identifier) + + if before_all_options.before_all: + log.step("Running before_all...") + env = before_all_options.environment.as_dictionary(prev_environment=os.environ) + env.setdefault("MACOSX_DEPLOYMENT_TARGET", "10.9") + before_all_prepared = prepare_command( + before_all_options.before_all, + project=".", + package=before_all_options.package_dir, + ) + shell(before_all_prepared, env=env) for config in python_configurations: build_options = options.build_options(config.identifier) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 874445fa..13b5c0c3 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -234,18 +234,20 @@ def build(options: Options, tmp_path: Path) -> None: options.globals.build_selector, options.globals.architectures ) - try: - if len(python_configurations) > 0: - before_all_options_identifier = python_configurations[0].identifier - before_all_options = options.build_options(before_all_options_identifier) + if len(python_configurations) == 0: + return - if before_all_options.before_all: - log.step("Running before_all...") - env = before_all_options.environment.as_dictionary(prev_environment=os.environ) - before_all_prepared = prepare_command( - before_all_options.before_all, project=".", package=options.globals.package_dir - ) - shell(before_all_prepared, env=env) + try: + before_all_options_identifier = python_configurations[0].identifier + before_all_options = options.build_options(before_all_options_identifier) + + if before_all_options.before_all: + log.step("Running before_all...") + env = before_all_options.environment.as_dictionary(prev_environment=os.environ) + before_all_prepared = prepare_command( + before_all_options.before_all, project=".", package=options.globals.package_dir + ) + shell(before_all_prepared, env=env) for config in python_configurations: build_options = options.build_options(config.identifier)