diff --git a/CHANGELOG.md b/CHANGELOG.md index c84d203a77..f099dda2e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ - Add links in `README.md` for `info` and `patch` commands ([#1722](https://github.com/nf-core/tools/issues/1722)]) - Fix misc. issues with `--branch` and `--base-path` ([#1726](https://github.com/nf-core/tools/issues/1726)) - Add `branch` field to module entries in `modules.json` to record what branch a module was installed from ([#1728](https://github.com/nf-core/tools/issues/1728)) +- Fix unbound variable issues and minor refactoring [#1742](https://github.com/nf-core/tools/pull/1742/) ## [v2.4.1 - Cobolt Koala Patch](https://github.com/nf-core/tools/releases/tag/2.4) - [2022-05-16] diff --git a/nf_core/modules/update.py b/nf_core/modules/update.py index 5ca96a1136..59e7ceaaa4 100644 --- a/nf_core/modules/update.py +++ b/nf_core/modules/update.py @@ -46,17 +46,6 @@ def __init__( self.modules_json = ModulesJson(self.dir) self.branch = branch - class DiffEnum(enum.Enum): - """Enumeration to keeping track of file diffs. - - Used for the --save-diff and --preview options - """ - - UNCHANGED = enum.auto() - CHANGED = enum.auto() - CREATED = enum.auto() - REMOVED = enum.auto() - def _parameter_checks(self): """Checks the compatibilty of the supplied parameters. @@ -431,18 +420,24 @@ def get_all_modules_info(self, branch=None): # Get the git urls from the modules.json modules_info = ( - (self.modules_json.get_git_url(repo_name), branch, self.modules_json.get_base_path(repo_name), mods_shas) + ( + repo_name, + self.modules_json.get_git_url(repo_name), + branch, + self.modules_json.get_base_path(repo_name), + mods_shas, + ) for (repo_name, branch), mods_shas in repos_and_branches.items() ) # Create ModulesRepo objects repo_objs_mods = [] - for repo_url, branch, base_path, mods_shas in modules_info: + for repo_name, repo_url, branch, base_path, mods_shas in modules_info: try: modules_repo = ModulesRepo(remote_url=repo_url, branch=branch, base_path=base_path) except LookupError as e: log.warning(e) - log.info(f"Skipping modules in '{modules_repo.fullname}'") + log.info(f"Skipping modules in '{repo_name}'") else: repo_objs_mods.append((modules_repo, mods_shas)) @@ -453,13 +448,13 @@ def get_all_modules_info(self, branch=None): # don't try to update those that don't i = 0 while i < len(modules_info): - repo, module, _ = modules_info[i] + repo, module, sha = modules_info[i] if not repo.module_exists(module): log.warning(f"Module '{module}' does not exist in '{repo.fullname}'. Skipping...") modules_info.pop(i) elif sha is not None and not repo.sha_exists_on_branch(sha): log.warning( - f"Git sha '{sha}' does not exists on the '{branch}' of '{repo.fullname}'. Skipping module '{mod}'" + f"Git sha '{sha}' does not exists on the '{repo.branch}' of '{repo.fullname}'. Skipping module '{module}'" ) modules_info.pop(i) else: