Skip to content

Commit 095c8b5

Browse files
authored
Merge pull request #3816 from mashehu/update-to-python-3_10
2 parents faadb21 + a054865 commit 095c8b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+288
-337
lines changed

.github/workflows/pytest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ jobs:
3434
runs-on: "ubuntu-latest"
3535
strategy:
3636
matrix:
37-
python-version: ["3.9", "3.14"]
37+
python-version: ["3.10", "3.14"]
3838
runner: ["ubuntu-latest"]
3939

4040
steps:
4141
- name: Check conditions
4242
id: conditions
43-
run: echo "run-tests=${{ github.ref == 'refs/heads/main' || (matrix.runner == 'ubuntu-20.04' && matrix.python-version == '3.9') }}" >> "$GITHUB_OUTPUT"
43+
run: echo "run-tests=${{ github.ref == 'refs/heads/main' || (matrix.runner == 'ubuntu-20.04' && matrix.python-version == '3.10') }}" >> "$GITHUB_OUTPUT"
4444

4545
outputs:
4646
python-version: ${{ matrix.python-version }}

nf_core/commands_pipelines.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33
import sys
44
from pathlib import Path
5-
from typing import Optional, Union
65

76
import rich
87

@@ -282,9 +281,9 @@ def pipelines_list(ctx, keywords, sort, json, show_archived):
282281
# nf-core pipelines rocrate
283282
def pipelines_rocrate(
284283
ctx,
285-
pipeline_dir: Union[str, Path],
286-
json_path: Optional[Union[str, Path]],
287-
zip_path: Optional[Union[str, Path]],
284+
pipeline_dir: str | Path,
285+
json_path: str | Path | None,
286+
zip_path: str | Path | None,
288287
pipeline_version: str,
289288
) -> None:
290289
from nf_core.pipelines.rocrate import ROCrate

nf_core/commands_test_datasets.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
from typing import Optional
32

43
import click
54
import rich
@@ -30,7 +29,7 @@ def test_datasets_list_remote(ctx: click.Context, branch: str, generate_nf_path:
3029

3130

3231
def test_datasets_search(
33-
ctx: click.Context, branch: str, generate_nf_path: bool, generate_dl_url: bool, query: Optional[str]
32+
ctx: click.Context, branch: str, generate_nf_path: bool, generate_dl_url: bool, query: str | None
3433
) -> None:
3534
"""
3635
Search all files on a given branch in the remote nf-core/testdatasets repository on github

nf_core/components/components_command.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import shutil
55
from pathlib import Path
6-
from typing import Optional, Union
76

87
import nf_core.utils
98
from nf_core.modules.modules_json import ModulesJson
@@ -22,9 +21,9 @@ class ComponentCommand:
2221
def __init__(
2322
self,
2423
component_type: str,
25-
directory: Union[str, Path] = ".",
26-
remote_url: Optional[str] = None,
27-
branch: Optional[str] = None,
24+
directory: str | Path = ".",
25+
remote_url: str | None = None,
26+
branch: str | None = None,
2827
no_pull: bool = False,
2928
hide_progress: bool = False,
3029
no_prompts: bool = False,
@@ -37,7 +36,7 @@ def __init__(
3736
self.modules_repo = ModulesRepo(remote_url, branch, no_pull, hide_progress)
3837
self.hide_progress: bool = hide_progress
3938
self.no_prompts: bool = no_prompts
40-
self.repo_type: Optional[str] = None
39+
self.repo_type: str | None = None
4140
self.org: str = ""
4241
self._configure_repo_and_paths()
4342

@@ -114,7 +113,7 @@ def has_modules_file(self) -> None:
114113
log.info("Creating missing 'module.json' file.")
115114
ModulesJson(self.directory).create()
116115

117-
def clear_component_dir(self, component_name: str, component_dir: Union[str, Path]) -> bool:
116+
def clear_component_dir(self, component_name: str, component_dir: str | Path) -> bool:
118117
"""
119118
Removes all files in the module/subworkflow directory
120119
@@ -161,7 +160,7 @@ def components_from_repo(self, install_dir: str) -> list[str]:
161160
]
162161

163162
def install_component_files(
164-
self, component_name: str, component_version: str, modules_repo: ModulesRepo, install_dir: Union[str, Path]
163+
self, component_name: str, component_version: str, modules_repo: ModulesRepo, install_dir: str | Path
165164
) -> bool:
166165
"""
167166
Installs a module/subworkflow into the given directory
@@ -263,7 +262,7 @@ def check_patch_paths(self, patch_path: Path, module_name: str) -> None:
263262
][module_name]["patch"] = str(patch_path.relative_to(self.directory.resolve()))
264263
modules_json.dump()
265264

266-
def check_if_in_include_stmts(self, component_path: str) -> dict[str, list[dict[str, Union[int, str]]]]:
265+
def check_if_in_include_stmts(self, component_path: str) -> dict[str, list[dict[str, int | str]]]:
267266
"""
268267
Checks for include statements in the main.nf file of the pipeline and a list of line numbers where the component is included
269268
Args:
@@ -272,7 +271,7 @@ def check_if_in_include_stmts(self, component_path: str) -> dict[str, list[dict[
272271
Returns:
273272
(list): A list of dictionaries, with the workflow file and the line number where the component is included
274273
"""
275-
include_stmts: dict[str, list[dict[str, Union[int, str]]]] = {}
274+
include_stmts: dict[str, list[dict[str, int | str]]] = {}
276275
if self.repo_type == "pipeline":
277276
workflow_files = Path(self.directory, "workflows").glob("*.nf")
278277
for workflow_file in workflow_files:

nf_core/components/components_differ.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import logging
55
import os
66
from pathlib import Path
7-
from typing import Union
87

98
from rich import box
109
from rich.console import Console, Group, RenderableType
@@ -308,7 +307,7 @@ def print_diff(
308307
)
309308

310309
@staticmethod
311-
def per_file_patch(patch_fn: Union[str, Path]) -> dict[str, list[str]]:
310+
def per_file_patch(patch_fn: str | Path) -> dict[str, list[str]]:
312311
"""
313312
Splits a patch file for several files into one patch per file.
314313
@@ -466,8 +465,8 @@ def try_apply_single_patch(file_lines, patch, reverse=False):
466465
def try_apply_patch(
467466
component_type: str,
468467
component: str,
469-
repo_path: Union[str, Path],
470-
patch_path: Union[str, Path],
468+
repo_path: str | Path,
469+
patch_path: str | Path,
471470
component_dir: Path,
472471
reverse: bool = False,
473472
) -> dict[str, list[str]]:

nf_core/components/components_test.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import os
77
import re
88
from pathlib import Path
9-
from typing import Optional
109

1110
import questionary
1211
from rich import print
@@ -65,15 +64,15 @@ class ComponentsTest(ComponentCommand): # type: ignore[misc]
6564
def __init__(
6665
self,
6766
component_type: str,
68-
component_name: Optional[str] = None,
67+
component_name: str | None = None,
6968
directory: str = ".",
7069
no_prompts: bool = False,
71-
remote_url: Optional[str] = None,
72-
branch: Optional[str] = None,
70+
remote_url: str | None = None,
71+
branch: str | None = None,
7372
verbose: bool = False,
7473
update: bool = False,
7574
once: bool = False,
76-
profile: Optional[str] = None,
75+
profile: str | None = None,
7776
):
7877
super().__init__(component_type, directory, remote_url, branch, no_prompts=no_prompts)
7978
self.component_name = component_name

nf_core/components/components_utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import re
33
from pathlib import Path
4-
from typing import Optional, Union
54

65
import questionary
76
import requests
@@ -22,7 +21,7 @@
2221
yaml.indent(mapping=2, sequence=2, offset=0)
2322

2423

25-
def get_repo_info(directory: Path, use_prompt: Optional[bool] = True) -> tuple[Path, Optional[str], str]:
24+
def get_repo_info(directory: Path, use_prompt: bool | None = True) -> tuple[Path, str | None, str]:
2625
"""
2726
Determine whether this is a pipeline repository or a clone of
2827
nf-core/modules
@@ -95,7 +94,7 @@ def prompt_component_version_sha(
9594
component_name: str,
9695
component_type: str,
9796
modules_repo: "ModulesRepo",
98-
installed_sha: Optional[str] = None,
97+
installed_sha: str | None = None,
9998
) -> str:
10099
"""
101100
Creates an interactive questionary prompt for selecting the module/subworkflow version
@@ -146,7 +145,7 @@ def prompt_component_version_sha(
146145

147146

148147
def get_components_to_install(
149-
subworkflow_dir: Union[str, Path],
148+
subworkflow_dir: str | Path,
150149
) -> tuple[list[dict[str, str]], list[dict[str, str]]]:
151150
"""
152151
Parse the subworkflow main.nf file to retrieve all imported modules and subworkflows.
@@ -198,7 +197,7 @@ def get_components_to_install(
198197
return list(modules.values()), list(subworkflows.values())
199198

200199

201-
def get_biotools_response(tool_name: str) -> Optional[dict]:
200+
def get_biotools_response(tool_name: str) -> dict | None:
202201
"""
203202
Try to get bio.tools information for 'tool'
204203
"""
@@ -237,7 +236,7 @@ def get_biotools_id(data: dict, tool_name: str) -> str:
237236

238237
def get_channel_info_from_biotools(
239238
data: dict, tool_name: str
240-
) -> Optional[tuple[DictWithStrAndTuple, DictWithStrAndTuple]]:
239+
) -> tuple[DictWithStrAndTuple, DictWithStrAndTuple] | None:
241240
"""
242241
Try to find input and output channels and the respective EDAM ontology terms
243242

nf_core/components/create.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import shutil
1010
import subprocess
1111
from pathlib import Path
12-
from typing import Optional, Union
1312

1413
import jinja2
1514
import questionary
@@ -41,12 +40,12 @@ def __init__(
4140
component_type: str,
4241
directory: Path = Path("."),
4342
component: str = "",
44-
author: Optional[str] = None,
45-
process_label: Optional[str] = None,
46-
has_meta: Optional[str] = None,
43+
author: str | None = None,
44+
process_label: str | None = None,
45+
has_meta: str | None = None,
4746
force: bool = False,
48-
conda_name: Optional[str] = None,
49-
conda_version: Optional[str] = None,
47+
conda_name: str | None = None,
48+
conda_version: str | None = None,
5049
empty_template: bool = False,
5150
migrate_pytest: bool = False, # TODO: Deprecate this flag in the future
5251
):
@@ -293,7 +292,7 @@ def _get_module_structure_components(self):
293292
default=True,
294293
)
295294

296-
def _render_template(self) -> Optional[bool]:
295+
def _render_template(self) -> bool | None:
297296
"""
298297
Create new module/subworkflow files with Jinja2.
299298
"""
@@ -560,7 +559,7 @@ def generate_meta_yml_file(self) -> None:
560559
)
561560

562561
if hasattr(self, "inputs"):
563-
inputs_array: list[Union[dict, list[dict]]] = []
562+
inputs_array: list[dict | list[dict]] = []
564563
for i, (input_name, ontologies) in enumerate(self.inputs.items()):
565564
channel_entry: dict[str, dict] = {
566565
input_name: {
@@ -609,9 +608,9 @@ def generate_meta_yml_file(self) -> None:
609608
meta_yml["input"][0]["bam"]["ontologies"][2].yaml_add_eol_comment("SAM", "edam")
610609

611610
if hasattr(self, "outputs"):
612-
outputs_dict: dict[str, Union[list, dict]] = {}
611+
outputs_dict: dict[str, list | dict] = {}
613612
for i, (output_name, ontologies) in enumerate(self.outputs.items()):
614-
channel_contents: list[Union[list[dict], dict]] = []
613+
channel_contents: list[list[dict] | dict] = []
615614
if self.has_meta:
616615
channel_contents.append(
617616
[

nf_core/components/info.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import os
33
from pathlib import Path
4-
from typing import Optional, Union
54

65
import questionary
76
import yaml
@@ -59,18 +58,18 @@ class ComponentInfo(ComponentCommand):
5958
def __init__(
6059
self,
6160
component_type: str,
62-
pipeline_dir: Union[str, Path],
61+
pipeline_dir: str | Path,
6362
component_name: str,
64-
remote_url: Optional[str] = None,
65-
branch: Optional[str] = None,
63+
remote_url: str | None = None,
64+
branch: str | None = None,
6665
no_pull: bool = False,
6766
):
6867
super().__init__(component_type, pipeline_dir, remote_url, branch, no_pull)
69-
self.meta: Optional[dict] = None
70-
self.local_path: Optional[Path] = None
71-
self.remote_location: Optional[str] = None
68+
self.meta: dict | None = None
69+
self.local_path: Path | None = None
70+
self.remote_location: str | None = None
7271
self.local: bool = False
73-
self.modules_json: Optional[ModulesJson] = None
72+
self.modules_json: ModulesJson | None = None
7473

7574
if self.repo_type == "pipeline":
7675
# Check modules directory structure
@@ -90,7 +89,7 @@ def _configure_repo_and_paths(self, nf_dir_req=False) -> None:
9089
"""
9190
return super()._configure_repo_and_paths(nf_dir_req)
9291

93-
def init_mod_name(self, component: Optional[str]) -> str:
92+
def init_mod_name(self, component: str | None) -> str:
9493
"""
9594
Makes sure that we have a module/subworkflow name before proceeding.
9695
@@ -170,11 +169,11 @@ def get_component_info(self):
170169

171170
return self.generate_component_info_help()
172171

173-
def get_local_yaml(self) -> Optional[dict]:
172+
def get_local_yaml(self) -> dict | None:
174173
"""Attempt to get the meta.yml file from a locally installed module/subworkflow.
175174
176175
Returns:
177-
Optional[dict]: Parsed meta.yml if found, None otherwise
176+
dict | None: Parsed meta.yml if found, None otherwise
178177
"""
179178

180179
if self.repo_type == "pipeline":
@@ -213,7 +212,7 @@ def get_local_yaml(self) -> Optional[dict]:
213212

214213
return {}
215214

216-
def get_remote_yaml(self) -> Optional[dict]:
215+
def get_remote_yaml(self) -> dict | None:
217216
"""Attempt to get the meta.yml file from a remote repo.
218217
219218
Returns:

nf_core/components/install.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import os
33
from pathlib import Path
4-
from typing import Optional, Union
54

65
import questionary
76
from rich import print
@@ -30,15 +29,15 @@
3029
class ComponentInstall(ComponentCommand):
3130
def __init__(
3231
self,
33-
pipeline_dir: Union[str, Path],
32+
pipeline_dir: str | Path,
3433
component_type: str,
3534
force: bool = False,
3635
prompt: bool = False,
37-
sha: Optional[str] = None,
38-
remote_url: Optional[str] = None,
39-
branch: Optional[str] = None,
36+
sha: str | None = None,
37+
remote_url: str | None = None,
38+
branch: str | None = None,
4039
no_pull: bool = False,
41-
installed_by: Optional[list[str]] = None,
40+
installed_by: list[str] | None = None,
4241
):
4342
super().__init__(component_type, pipeline_dir, remote_url, branch, no_pull)
4443
self.current_remote = ModulesRepo(remote_url, branch)
@@ -52,7 +51,7 @@ def __init__(
5251
else:
5352
self.installed_by = [self.component_type]
5453

55-
def install(self, component: Union[str, dict[str, str]], silent: bool = False) -> bool:
54+
def install(self, component: str | dict[str, str], silent: bool = False) -> bool:
5655
if isinstance(component, dict):
5756
# Override modules_repo when the component to install is a dependency from a subworkflow.
5857
remote_url = component.get("git_remote", self.current_remote.remote_url)
@@ -211,7 +210,7 @@ def install_included_components(self, subworkflow_dir):
211210
self.installed_by = original_installed
212211

213212
def collect_and_verify_name(
214-
self, component: Optional[str], modules_repo: "nf_core.modules.modules_repo.ModulesRepo"
213+
self, component: str | None, modules_repo: "nf_core.modules.modules_repo.ModulesRepo"
215214
) -> str:
216215
"""
217216
Collect component name.

0 commit comments

Comments
 (0)