Skip to content

Commit

Permalink
Merge pull request #3317 from lmReef/fix-linting-error
Browse files Browse the repository at this point in the history
Fix meta_yml linting error
  • Loading branch information
lmReef authored Dec 6, 2024
2 parents b2132cf + cc38f8d commit 0450503
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
### Linting

- allow mixed `str` and `dict` entries in lint config ([#3228](https://github.com/nf-core/tools/pull/3228))
- fix meta_yml linting test failing due to module.process_name always being "" ([#3317](https://github.com/nf-core/tools/pull/3317))
- fix module section regex matching wrong things ([#3321](https://github.com/nf-core/tools/pull/3321))

### Modules
Expand Down
10 changes: 9 additions & 1 deletion nf_core/components/nfcore_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def __init__(
# Initialize the important files
self.main_nf: Path = Path(self.component_dir, "main.nf")
self.meta_yml: Optional[Path] = Path(self.component_dir, "meta.yml")
self.process_name = ""
self.environment_yml: Optional[Path] = Path(self.component_dir, "environment.yml")

component_list = self.component_name.split("/")
Expand Down Expand Up @@ -96,6 +95,8 @@ def __init__(
self.test_yml = None
self.test_main_nf = None

self.process_name: str = self._get_process_name()

def __repr__(self) -> str:
return f"<NFCoreComponent {self.component_name} {self.component_dir} {self.repo_url}>"

Expand Down Expand Up @@ -169,6 +170,13 @@ def _get_included_components_in_chained_tests(self, main_nf_test: Union[Path, st
included_components.append(component)
return included_components

def _get_process_name(self):
with open(self.main_nf) as fh:
for line in fh:
if re.search(r"^\s*process\s*\w*\s*{", line):
return re.search(r"^\s*process\s*(\w*)\s*{.*", line).group(1) or ""
return ""

def get_inputs_from_main_nf(self) -> None:
"""Collect all inputs from the main.nf file."""
inputs: Any = [] # Can be 'list[list[dict[str, dict[str, str]]]]' or 'list[str]'
Expand Down
1 change: 0 additions & 1 deletion nf_core/modules/lint/main_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ def check_process_section(self, lines, registry, fix_version, progress_bar):
bioconda_packages = []

# Process name should be all capital letters
self.process_name = lines[0].split()[1]
if all(x.upper() for x in self.process_name):
self.passed.append(("process_capitals", "Process name is in capital letters", self.main_nf))
else:
Expand Down

0 comments on commit 0450503

Please sign in to comment.