33import os
44import shutil
55from pathlib import Path
6- from typing import Optional , Union
76
87import nf_core .utils
98from 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 :
0 commit comments