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

Update pre-commit hook astral-sh/ruff-pre-commit to v0.9.3 #3413

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
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
Expand Down
4 changes: 1 addition & 3 deletions nf_core/components/components_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}'")
Expand Down
4 changes: 2 additions & 2 deletions nf_core/components/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
)
Expand Down
2 changes: 1 addition & 1 deletion nf_core/components/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion nf_core/components/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion nf_core/modules/lint/meta_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def meta_yml(module_lint_object: ComponentLint, module: NFCoreComponent) -> None
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
Expand Down
6 changes: 3 additions & 3 deletions nf_core/pipelines/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipelines/lint/multiqc_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'.")
Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipelines/lint/version_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()])
)
)
Expand Down
4 changes: 2 additions & 2 deletions nf_core/pipelines/params_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "## ----------------------------------------------------------------------------"
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipelines/rocrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipelines/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipelines/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion nf_core/subworkflows/lint/meta_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def meta_yml(subworkflow_lint_object, subworkflow):
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 {e.path[0] + '.' + e.path[2]} are indented correctly."
subworkflow.failed.append(
(
"meta_yml_valid",
Expand Down
18 changes: 9 additions & 9 deletions tests/modules/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,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"""
Expand Down
10 changes: 6 additions & 4 deletions tests/pipelines/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Loading