Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused arguments #1818

Merged
merged 16 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Bump promoted Python version from 3.7 to 3.8 ([#1971](https://github.com/nf-core/tools/pull/1971))
- Fix incorrect file deletion in `nf-core launch` when `--params_in` has the same name as `--params_out`
- Updated GitHub actions ([#1998](https://github.com/nf-core/tools/pull/1998), [#2001](https://github.com/nf-core/tools/pull/2001))
- Code maintenance ([#1818](https://github.com/nf-core/tools/pull/1818))
- Track from where modules and subworkflows are installed ([#1999](https://github.com/nf-core/tools/pull/1999))
- Substitute ModulesCommand and SubworkflowsCommand by ComponentsCommand ([#2000](https://github.com/nf-core/tools/pull/2000))
- Don't print source file + line number on logging messages (except when verbose) ([#2015](https://github.com/nf-core/tools/pull/2015))
Expand Down Expand Up @@ -55,7 +56,7 @@
- Update MultiQC module, update supplying MultiQC default and custom config and logo files to module
- Add a 'recommend' methods description text to MultiQC to help pipeline users report pipeline usage in publications ([#1749](https://github.com/nf-core/tools/pull/1749))
- Fix template spacing modified by JINJA ([#1830](https://github.com/nf-core/tools/pull/1830))
- Fix MultiQC execution on template [#1855](https://github.com/nf-core/tools/pull/1855)
- Fix MultiQC execution on template ([#1855](https://github.com/nf-core/tools/pull/1855))
- Don't skip including `base.config` when skipping nf-core/configs

### Linting
Expand Down
2 changes: 1 addition & 1 deletion nf_core/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def run_linting(
lint_obj._print_results(show_passed)
module_lint_obj._print_results(show_passed)
nf_core.lint_utils.print_joint_summary(lint_obj, module_lint_obj)
nf_core.lint_utils.print_fixes(lint_obj, module_lint_obj)
nf_core.lint_utils.print_fixes(lint_obj)

# Save results to Markdown file
if md_fn is not None:
Expand Down
16 changes: 9 additions & 7 deletions nf_core/lint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ def print_joint_summary(lint_obj, module_lint_obj):
console.print(table)


def print_fixes(lint_obj, module_lint_obj):
def print_fixes(lint_obj):
"""Prints available and applied fixes"""

if len(lint_obj.could_fix):
fix_cmd = "nf-core lint {} --fix {}".format(
"" if lint_obj.wf_path == "." else f"--dir {lint_obj.wf_path}", " --fix ".join(lint_obj.could_fix)
)
if lint_obj.could_fix:
fix_flags = "".join([f" --fix {fix}" for fix in lint_obj.could_fix])
wf_dir = "" if lint_obj.wf_path == "." else f"--dir {lint_obj.wf_path}"
fix_cmd = f"nf-core lint {wf_dir} {fix_flags}"
console.print(
f"\nTip: Some of these linting errors can automatically be resolved with the following command:\n\n[blue] {fix_cmd}\n"
"\nTip: Some of these linting errors can automatically be resolved with the following command:\n\n"
f"[blue] {fix_cmd}\n"
)
if len(lint_obj.fix):
console.print(
"Automatic fixes applied. Please check with 'git diff' and revert any changes you do not want with 'git checkout <file>'."
"Automatic fixes applied. "
"Please check with 'git diff' and revert any changes you do not want with 'git checkout <file>'."
)


Expand Down
1 change: 0 additions & 1 deletion nf_core/modules/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def lint(
module=None,
key=(),
all_modules=False,
hide_progress=False,
print_results=True,
show_passed=False,
local=False,
Expand Down
19 changes: 10 additions & 9 deletions nf_core/modules/lint/main_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,18 @@ def main_nf(module_lint_object, module, fix_version, progress_bar):
continue

# Perform state-specific linting checks
if state == "process" and not _is_empty(module, l):
if state == "process" and not _is_empty(l):
process_lines.append(l)
if state == "input" and not _is_empty(module, l):
if state == "input" and not _is_empty(l):
inputs.extend(_parse_input(module, l))
if state == "output" and not _is_empty(module, l):
if state == "output" and not _is_empty(l):
outputs += _parse_output(module, l)
outputs = list(set(outputs)) # remove duplicate 'meta's
if state == "when" and not _is_empty(module, l):
if state == "when" and not _is_empty(l):
when_lines.append(l)
if state == "script" and not _is_empty(module, l):
if state == "script" and not _is_empty(l):
script_lines.append(l)
if state == "shell" and not _is_empty(module, l):
if state == "shell" and not _is_empty(l):
shell_lines.append(l)

# Check that we have required sections
Expand Down Expand Up @@ -390,7 +390,7 @@ def _parse_output(self, line):
return output


def _is_empty(self, line):
def _is_empty(line):
"""Check whether a line is empty or a comment"""
empty = False
if line.strip().startswith("//"):
Expand Down Expand Up @@ -421,7 +421,7 @@ def _fix_module_version(self, current_version, latest_version, singularity_tag,
build_type = _container_type(l)
if build_type == "bioconda":
new_lines.append(re.sub(rf"{current_version}", f"{latest_version}", line))
elif build_type == "singularity" or build_type == "docker":
elif build_type in ("singularity", "docker"):
# Check that the new url is valid
new_url = re.search(
"(?:['\"])(.+)(?:['\"])", re.sub(rf"{singularity_tag}", f"{latest_version}--{build}", line)
Expand All @@ -431,7 +431,8 @@ def _fix_module_version(self, current_version, latest_version, singularity_tag,
"https://" + new_url if not new_url.startswith("https://") else new_url, stream=True
)
log.debug(
f"Connected to URL: {'https://' + new_url if not new_url.startswith('https://') else new_url}, status_code: {response_new_container.status_code}"
f"Connected to URL: {'https://' + new_url if not new_url.startswith('https://') else new_url}, "
f"status_code: {response_new_container.status_code}"
)
except (requests.exceptions.RequestException, sqlite3.InterfaceError) as e:
log.debug(f"Unable to connect to url '{new_url}' due to error: {e}")
Expand Down
2 changes: 1 addition & 1 deletion nf_core/modules/lint/module_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
log = logging.getLogger(__name__)


def module_deprecations(module_lint_object, module):
def module_deprecations(_, module):
"""
Check that the modules are up to the latest nf-core standard
"""
Expand Down
2 changes: 1 addition & 1 deletion nf_core/modules/lint/module_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
log = logging.getLogger(__name__)


def module_tests(module_lint_object, module):
def module_tests(_, module):
"""
Lint the tests of a module in ``nf-core/modules``

Expand Down
2 changes: 1 addition & 1 deletion nf_core/modules/lint/module_todos.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
log = logging.getLogger(__name__)


def module_todos(module_lint_object, module):
def module_todos(_, module):
"""
Look for TODO statements in the module files

Expand Down
12 changes: 8 additions & 4 deletions nf_core/modules/test_yml_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def run(self):
"""Run build steps"""
if not self.no_prompts:
log.info(
"[yellow]Press enter to use default values [cyan bold](shown in brackets) [yellow]or type your own responses"
"[yellow]Press enter to use default values "
"[cyan bold](shown in brackets) [yellow]or type your own responses"
)
self.check_inputs()
self.scrape_workflow_entry_points()
Expand Down Expand Up @@ -170,7 +171,10 @@ def build_single_test(self, entry_point):
while ep_test["command"] == "":
# Don't think we need the last `-c` flag, but keeping to avoid having to update 100s modules.
# See https://github.com/nf-core/tools/issues/1562
default_val = f"nextflow run ./tests/modules/nf-core/{self.module_name} -entry {entry_point} -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/{self.module_name}/nextflow.config"
default_val = (
f"nextflow run ./tests/modules/nf-core/{self.module_name} -entry {entry_point} "
f"-c ./tests/config/nextflow.config -c ./tests/modules/nf-core/{self.module_name}/nextflow.config"
)
if self.no_prompts:
ep_test["command"] = default_val
else:
Expand All @@ -192,7 +196,7 @@ def build_single_test(self, entry_point):
).strip()
ep_test["tags"] = [t.strip() for t in prompt_tags.split(",")]

ep_test["files"] = self.get_md5_sums(entry_point, ep_test["command"])
ep_test["files"] = self.get_md5_sums(ep_test["command"])

return ep_test

Expand Down Expand Up @@ -253,7 +257,7 @@ def create_test_file_dict(self, results_dir, is_repeat=False):

return test_files

def get_md5_sums(self, entry_point, command, results_dir=None, results_dir_repeat=None):
def get_md5_sums(self, command, results_dir=None, results_dir_repeat=None):
"""
Recursively go through directories and subdirectories
and generate tuples of (<file_path>, <md5sum>)
Expand Down
6 changes: 3 additions & 3 deletions nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,22 +338,22 @@ def setup_requests_cachedir():
return config


def wait_cli_function(poll_func, poll_every=20):
def wait_cli_function(poll_func, refresh_per_second=20):
"""
Display a command-line spinner while calling a function repeatedly.

Keep waiting until that function returns True

Arguments:
poll_func (function): Function to call
poll_every (int): How many tenths of a second to wait between function calls. Default: 20.
refresh_per_second (int): Refresh this many times per second. Default: 20.

Returns:
None. Just sits in an infite loop until the function returns True.
"""
try:
spinner = Spinner("dots2", "Use ctrl+c to stop waiting and force exit.")
with Live(spinner, refresh_per_second=20):
with Live(spinner, refresh_per_second=refresh_per_second):
fabianegli marked this conversation as resolved.
Show resolved Hide resolved
while True:
if poll_func():
break
Expand Down
4 changes: 1 addition & 3 deletions tests/modules/create_test_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def test_modules_create_test_yml_get_md5(self, test_file_dir):
meta_builder = nf_core.modules.ModulesTestYmlBuilder("test/tool", self.pipeline_dir, False, "./", False, True)
with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh:
fh.write("this line is just for testing")
test_files = meta_builder.get_md5_sums(
entry_point="dummy", command="dummy", results_dir=test_file_dir, results_dir_repeat=test_file_dir
)
test_files = meta_builder.get_md5_sums(command="dummy", results_dir=test_file_dir, results_dir_repeat=test_file_dir)
assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786"


Expand Down