Repository navigation
refactor: flatten deeply nested logic with early returns and guard clauses - #368
Merged
Merged
Conversation
jvolkman
commented
Oct 17, 2026
| if _matches(name): | ||
| return z.read(name).decode("utf-8") | ||
| elif archive_path.name.endswith((".tar.gz", ".tgz", ".tar.bz2", ".tar")): | ||
| return "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Flattens deeply nested control flow (
if/elsepyramids) acrosspycross/private/andmodules/backend_maturin/using early returns, guard statements withcontinue, and small focused helper functions:translator_common.bzl,uv_lock_model.bzl,poetry_lock_model.bzl,pylock_lock_model.bzl):_read_project_dictand_resolve_local_dep_constraintintranslator_common.bzlusing early returns andcontinueguards; flatten package deduplication, dependency matching, and pin resolution loops inresolve_lock_graph._resolve_uv_dep_constraintand_parse_sdist_fileinuv_lock_model.bzl, and flatten_resolve_package_requires_python,_parse_uv_dependency, and group/member iteration withcontinueguards._resolve_pylock_project_pinsinpylock_lock_model.bzland flatteninclude-group, BFS reachability, and fork-pin construction loops._get_files_for_packageand group filtering inpoetry_lock_model.bzl.lock_resolver.bzl,lock_common.bzl,lock_repo_creation.bzl,resolved_lock_renderer.bzl,thin_package_repo.bzl,sdist_repo.bzl,pypi_file.bzl,format_extension.bzl,backends.bzl):_synthesize_extra_packageinlock_resolver.bzland usecontinueguards in_create_package_resolverand_compute_cycle_groups._create_remote_file_repoinlock_repo_creation.bzland_extract_hrefinpypi_file.bzl.lock_common.bzl,format_extension.bzl,backends.bzl,resolved_lock_renderer.bzl,thin_package_repo.bzl, andsdist_repo.bzl.cycle_dep_needed.bzl,cycle_member_marker_deps.bzl,pep508_marker_values.bzl,wheel_library.bzl,modules_mapping.bzl,build/rules/common_attrs.bzl):_register_wheel_install_actionand_build_venv_symlinksinwheel_library.bzl,_node_envincycle_dep_needed.bzl, and_toolchain_py3_runtimeinpep508_marker_values.bzl.cycle_member_marker_deps.bzl,modules_mapping.bzl, andcommon_attrs.bzl.inspect_package.py,cc_toolchain.py,generate_cargo_lock.py,rust_common.py):_find_cargo_toml_dir_from_pyprojectingenerate_cargo_lock.py(withopen(pyproject_path)inside the fallbacktry/except) and_symlink_stdlibinrust_common.py.continueguards ininspect_package.pyandcc_toolchain.py(get_wrapper_flagsnow matches exact flag names viapartition("=")before readingsplit_cflags[i + 1], avoiding anIndexErrorif the last flag only shares a prefix like--sysroots).