Skip to content

Commit 4500ae5

Browse files
committed
fix linting
1 parent efd1176 commit 4500ae5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

nf_core/components/nfcore_component.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def get_topics_from_main_nf(self) -> None:
299299
with open(self.main_nf) as f:
300300
data = f.read()
301301
if self.component_type == "modules":
302-
topics = {}
302+
topics: dict[str, list[dict[str, dict] | list[dict[str, dict[str, str]]]]] = {}
303303
# get topic name from main.nf after "output:". the names are always after "topic:"
304304
if "output:" not in data:
305305
log.debug(f"Could not find any outputs in {self.main_nf}")
@@ -313,7 +313,7 @@ def get_topics_from_main_nf(self) -> None:
313313
matches_elements = re.finditer(regex_elements, line)
314314
if not match_topic:
315315
continue
316-
channel_elements = []
316+
channel_elements: list[dict[str, dict]] = []
317317
topic_name = match_topic.group(1)
318318
if topic_name in topics:
319319
continue

nf_core/modules/lint/main_nf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def _parse_input(self, line_raw):
720720
return inputs
721721

722722

723-
def _parse_output_emits(self, line:str) -> list[str]:
723+
def _parse_output_emits(self, line: str) -> list[str]:
724724
output = []
725725
if "meta" in line:
726726
output.append("meta")
@@ -732,7 +732,7 @@ def _parse_output_emits(self, line:str) -> list[str]:
732732
return output
733733

734734

735-
def _parse_output_topics(self, line:str) -> list[str]:
735+
def _parse_output_topics(self, line: str) -> list[str]:
736736
output = []
737737
if "meta" in line:
738738
output.append("meta")

tests/modules/lint/test_main_nf.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def setUp(self):
115115
if not self.mods_install.install("bamstats/generalstats"):
116116
self.skipTest("Could not install samtools/sort module")
117117

118-
119118
def test_main_nf_lint_with_alternative_registry(self):
120119
"""Test main.nf linting with alternative container registry"""
121120
# Test with alternative registry - should warn/fail when containers don't match the registry
@@ -142,12 +141,16 @@ def test_topics_and_emits_version_check(self):
142141
module_lint = nf_core.modules.lint.ModuleLint(directory=self.pipeline_dir)
143142
module_lint.lint(print_results=False, module="samtools/sort")
144143
assert len(module_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}"
145-
assert len(module_lint.warned) == 2, f"Linting warned with {[x.__dict__ for x in module_lint.warned]}, expected 2 warnings"
144+
assert len(module_lint.warned) == 2, (
145+
f"Linting warned with {[x.__dict__ for x in module_lint.warned]}, expected 2 warnings"
146+
)
146147
assert len(module_lint.passed) > 0
147-
148+
148149
# Lint a module known to have topics as output in main.nf
149150
module_lint = nf_core.modules.lint.ModuleLint(directory=self.pipeline_dir)
150151
module_lint.lint(print_results=False, module="bamstats/generalstats")
151152
assert len(module_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}"
152-
assert len(module_lint.warned) == 0, f"Linting warned with {[x.__dict__ for x in module_lint.warned]}, expected 1 warning"
153-
assert len(module_lint.passed) > 0
153+
assert len(module_lint.warned) == 0, (
154+
f"Linting warned with {[x.__dict__ for x in module_lint.warned]}, expected 1 warning"
155+
)
156+
assert len(module_lint.passed) > 0

0 commit comments

Comments
 (0)