Skip to content

Commit

Permalink
Merge pull request #3413 from nf-core/renovate/astral-sh-ruff-pre-com…
Browse files Browse the repository at this point in the history
…mit-0.x

Update pre-commit hook astral-sh/ruff-pre-commit to v0.9.3
mashehu authored Jan 27, 2025

Verified

This commit was signed with the committer’s verified signature.
jtraglia Justin Traglia
2 parents 3be4b60 + 61d9710 commit 2f71183
Showing 16 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.3
hooks:
- id: ruff # linter
args: [--fix, --exit-non-zero-on-fix] # sort imports and fix
4 changes: 1 addition & 3 deletions nf_core/components/components_differ.py
Original file line number Diff line number Diff line change
@@ -271,9 +271,7 @@ def print_diff(
console = Console(force_terminal=nf_core.utils.rich_force_colors())
if current_version is not None and new_version is not None:
log.info(
f"Changes in component '{Path(repo_path, component)}' between"
f" ({current_version}) and"
f" ({new_version})"
f"Changes in component '{Path(repo_path, component)}' between ({current_version}) and ({new_version})"
)
else:
log.info(f"Changes in component '{Path(repo_path, component)}'")
4 changes: 2 additions & 2 deletions nf_core/components/info.py
Original file line number Diff line number Diff line change
@@ -265,9 +265,9 @@ def generate_component_info_help(self):
intro_text.append(
Text.from_markup(
":globe_with_meridians: Repository: "
f"{ '[link={self.remote_location}]' if self.remote_location.startswith('http') else ''}"
f"{'[link={self.remote_location}]' if self.remote_location.startswith('http') else ''}"
f"{self.remote_location}"
f"{'[/link]' if self.remote_location.startswith('http') else '' }"
f"{'[/link]' if self.remote_location.startswith('http') else ''}"
"\n"
)
)
2 changes: 1 addition & 1 deletion nf_core/components/lint/__init__.py
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ def __init__(
continue
if isinstance(components, str):
raise LookupError(
f"Error parsing modules.json: {components}. " f"Please check the file for errors or try again."
f"Error parsing modules.json: {components}. Please check the file for errors or try again."
)
for org, comp in components:
self.all_remote_components.append(
2 changes: 1 addition & 1 deletion nf_core/components/remove.py
Original file line number Diff line number Diff line change
@@ -176,6 +176,6 @@ def remove(self, component, removed_by=None, removed_components=None, force=Fals
f"Did not remove '{component}', because it was also manually installed. Only updated 'installed_by' entry in modules.json."
)
log.info(
f"""Did not remove {self.component_type[:-1]} '{component}', because it was also installed by {', '.join(f"'{d}'" for d in installed_by)}. Only updated the 'installed_by' entry in modules.json."""
f"""Did not remove {self.component_type[:-1]} '{component}', because it was also installed by {", ".join(f"'{d}'" for d in installed_by)}. Only updated the 'installed_by' entry in modules.json."""
)
return removed
4 changes: 2 additions & 2 deletions nf_core/modules/lint/meta_yml.py
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ def meta_yml(module_lint_object: ComponentLint, module: NFCoreComponent, allow_m
).get("meta.yml")
if lines is not None:
yaml = ruamel.yaml.YAML()
meta_yaml = yaml.safe_load("".join(lines))
meta_yaml = yaml.load("".join(lines))
if meta_yaml is None:
module.failed.append(("meta_yml_exists", "Module `meta.yml` does not exist", module.meta_yml))
return
@@ -82,7 +82,7 @@ def meta_yml(module_lint_object: ComponentLint, module: NFCoreComponent, allow_m
if len(e.path) > 0:
hint = f"\nCheck the entry for `{e.path[0]}`."
if e.message.startswith("None is not of type 'object'") and len(e.path) > 2:
hint = f"\nCheck that the child entries of {str(e.path[0])+'.'+str(e.path[2])} are indented correctly."
hint = f"\nCheck that the child entries of {str(e.path[0]) + '.' + str(e.path[2])} are indented correctly."
if e.schema and isinstance(e.schema, dict) and "message" in e.schema:
e.message = e.schema["message"]
incorrect_value = meta_yaml
6 changes: 3 additions & 3 deletions nf_core/pipelines/download.py
Original file line number Diff line number Diff line change
@@ -202,7 +202,7 @@ def download_workflow(self):
raise DownloadError(e) from e

summary_log = [
f"Pipeline revision: '{', '.join(self.revision) if len(self.revision) < 5 else self.revision[0]+',['+str(len(self.revision)-2)+' more revisions],'+self.revision[-1]}'",
f"Pipeline revision: '{', '.join(self.revision) if len(self.revision) < 5 else self.revision[0] + ',[' + str(len(self.revision) - 2) + ' more revisions],' + self.revision[-1]}'",
f"Use containers: '{self.container_system}'",
]
if self.container_system:
@@ -1908,8 +1908,8 @@ def __init__(

log.error(self.error_type.message)
log.info(self.error_type.helpmessage)
log.debug(f'Failed command:\n{" ".join(singularity_command)}')
log.debug(f'Singularity error messages:\n{"".join(error_msg)}')
log.debug(f"Failed command:\n{' '.join(singularity_command)}")
log.debug(f"Singularity error messages:\n{''.join(error_msg)}")

raise self.error_type

2 changes: 1 addition & 1 deletion nf_core/pipelines/lint/multiqc_config.py
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ def multiqc_config(self) -> Dict[str, List[str]]:
f"The expected comment is: \n"
f"```{hint}``` \n"
f"The current comment is: \n"
f"```{ mqc_yml['report_comment'].strip()}```"
f"```{mqc_yml['report_comment'].strip()}```"
)
else:
passed.append("`assets/multiqc_config.yml` contains a matching 'report_comment'.")
2 changes: 1 addition & 1 deletion nf_core/pipelines/lint/version_consistency.py
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ def version_consistency(self):
# Check if they are consistent
if len(set(versions.values())) != 1:
failed.append(
"The versioning is not consistent between container, release tag " "and config. Found {}".format(
"The versioning is not consistent between container, release tag and config. Found {}".format(
", ".join([f"{k} = {v}" for k, v in versions.items()])
)
)
4 changes: 2 additions & 2 deletions nf_core/pipelines/params_file.py
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
"of nextflow run with the {pipeline_name} pipeline."
)

USAGE = "Uncomment lines with a single '#' if you want to pass the parameter " "to the pipeline."
USAGE = "Uncomment lines with a single '#' if you want to pass the parameter to the pipeline."

H1_SEPERATOR = "## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
H2_SEPERATOR = "## ----------------------------------------------------------------------------"
@@ -107,7 +107,7 @@ def get_pipeline(self) -> Optional[bool]:
# Prompt for pipeline if not supplied
if self.pipeline is None:
launch_type = questionary.select(
"Generate parameter file for local pipeline " "or remote GitHub pipeline?",
"Generate parameter file for local pipeline or remote GitHub pipeline?",
choices=["Remote pipeline", "Local path"],
style=nf_core.utils.nfcore_question_style,
).unsafe_ask()
2 changes: 1 addition & 1 deletion nf_core/pipelines/rocrate.py
Original file line number Diff line number Diff line change
@@ -212,7 +212,7 @@ def set_main_entity(self, main_entity_filename: str):
else:
url = self.version
self.crate.mainEntity.append_to(
"url", f"https://nf-co.re/{self.crate.name.replace('nf-core/','')}/{url}/", compact=True
"url", f"https://nf-co.re/{self.crate.name.replace('nf-core/', '')}/{url}/", compact=True
)
self.crate.mainEntity.append_to("version", self.version, compact=True)

2 changes: 1 addition & 1 deletion nf_core/pipelines/schema.py
Original file line number Diff line number Diff line change
@@ -770,7 +770,7 @@ def build_schema(self, pipeline_dir, no_prompts, web_only, url):
if self.web_schema_build_web_url:
log.info(
"To save your work, open {}\n"
f"Click the blue 'Finished' button, copy the schema and paste into this file: { self.web_schema_build_web_url, self.schema_filename}"
f"Click the blue 'Finished' button, copy the schema and paste into this file: {self.web_schema_build_web_url, self.schema_filename}"
)
return False

2 changes: 1 addition & 1 deletion nf_core/pipelines/sync.py
Original file line number Diff line number Diff line change
@@ -345,7 +345,7 @@ def create_merge_base_branch(self):
if merge_branch_format.match(branch)
]
)
new_branch = f"{self.original_merge_branch}-{max_branch+1}"
new_branch = f"{self.original_merge_branch}-{max_branch + 1}"
log.info(f"Branch already existed: '{self.merge_branch}', creating branch '{new_branch}' instead.")
self.merge_branch = new_branch

7 changes: 4 additions & 3 deletions nf_core/subworkflows/lint/meta_yml.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
from pathlib import Path

import jsonschema.validators
import yaml
import ruamel.yaml

import nf_core.components.components_utils
from nf_core.components.lint import LintExceptionError
@@ -43,7 +43,8 @@ def meta_yml(subworkflow_lint_object, subworkflow, allow_missing: bool = False):

try:
with open(subworkflow.meta_yml) as fh:
meta_yaml = yaml.safe_load(fh)
yaml = ruamel.yaml.YAML(typ="safe")
meta_yaml = yaml.load(fh)
subworkflow.passed.append(("meta_yml_exists", "Subworkflow `meta.yml` exists", subworkflow.meta_yml))
except FileNotFoundError:
subworkflow.failed.append(("meta_yml_exists", "Subworkflow `meta.yml` does not exist", subworkflow.meta_yml))
@@ -62,7 +63,7 @@ def meta_yml(subworkflow_lint_object, subworkflow, allow_missing: bool = False):
if len(e.path) > 0:
hint = f"\nCheck the entry for `{e.path[0]}`."
if e.message.startswith("None is not of type 'object'") and len(e.path) > 2:
hint = f"\nCheck that the child entries of {e.path[0]}.{e.path[2]} are indented correctly."
hint = f"\nCheck that the child entries of {str(e.path[0]) + '.' + str(e.path[2])} are indented correctly."
subworkflow.failed.append(
(
"meta_yml_valid",
18 changes: 9 additions & 9 deletions tests/modules/test_lint.py
Original file line number Diff line number Diff line change
@@ -296,15 +296,15 @@ def test_modules_lint_check_url(self):
if line.strip():
check_container_link_line(mocked_ModuleLint, line, registry="quay.io")

assert (
len(mocked_ModuleLint.passed) == passed
), f"{test}: Expected {passed} PASS, got {len(mocked_ModuleLint.passed)}."
assert (
len(mocked_ModuleLint.warned) == warned
), f"{test}: Expected {warned} WARN, got {len(mocked_ModuleLint.warned)}."
assert (
len(mocked_ModuleLint.failed) == failed
), f"{test}: Expected {failed} FAIL, got {len(mocked_ModuleLint.failed)}."
assert len(mocked_ModuleLint.passed) == passed, (
f"{test}: Expected {passed} PASS, got {len(mocked_ModuleLint.passed)}."
)
assert len(mocked_ModuleLint.warned) == warned, (
f"{test}: Expected {warned} WARN, got {len(mocked_ModuleLint.warned)}."
)
assert len(mocked_ModuleLint.failed) == failed, (
f"{test}: Expected {failed} FAIL, got {len(mocked_ModuleLint.failed)}."
)

def test_modules_lint_update_meta_yml(self):
"""update the meta.yml of a module"""
10 changes: 6 additions & 4 deletions tests/pipelines/test_create.py
Original file line number Diff line number Diff line change
@@ -158,9 +158,9 @@ def test_template_customisation_all_files_grouping(self):
str_path = str((Path(root) / file).relative_to(PIPELINE_TEMPLATE))
if str_path not in base_required_files:
try:
assert (
str_path in all_skipped_files
), f"Template file `{str_path}` not present in a group for pipeline customisation in `template_features.yml`."
assert str_path in all_skipped_files, (
f"Template file `{str_path}` not present in a group for pipeline customisation in `template_features.yml`."
)
except AssertionError:
if "/" in str_path:
# Check if the parent directory is in the skipped files
@@ -170,6 +170,8 @@ def test_template_customisation_all_files_grouping(self):
if upper_dir in all_skipped_files:
upper_dir_present = True
break
assert upper_dir_present, f"Template file `{str_path}` not present in a group for pipeline customisation in `template_features.yml`."
assert upper_dir_present, (
f"Template file `{str_path}` not present in a group for pipeline customisation in `template_features.yml`."
)
else:
raise

0 comments on commit 2f71183

Please sign in to comment.