Skip to content

Commit

Permalink
Add missing type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Oct 31, 2023
1 parent 49c8a7a commit 88c02a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bin/extract_galaxy_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# BIOTOOLS_API_URL = "https://130.226.25.21"


def read_file(filepath) -> List[str]:
def read_file(filepath: Optional[str]) -> List[str]:
"""
Read an optional file with 1 element per line
Expand All @@ -40,7 +40,7 @@ def read_file(filepath) -> List[str]:
return []


def get_string_content(cf):
def get_string_content(cf: ContentFile) -> str:
"""
Get string of the content from a ContentFile
Expand Down Expand Up @@ -81,7 +81,7 @@ def get_github_repo(url: str, g: Github) -> Repository:
return g.get_user(u_split[-2]).get_repo(u_split[-1])


def get_shed_attribute(attrib, shed_content, empty_value):
def get_shed_attribute(attrib: str, shed_content: Dict[str, Any], empty_value: Any) -> Any:
"""
Get a shed attribute
Expand All @@ -95,7 +95,7 @@ def get_shed_attribute(attrib, shed_content, empty_value):
return empty_value


def get_biotools(el):
def get_biotools(el: et.Element) -> Optional[str]:
"""
Get bio.tools information
Expand All @@ -109,7 +109,7 @@ def get_biotools(el):
return None


def get_conda_package(el):
def get_conda_package(el: et.Element) -> Optional[str]:
"""
Get conda package information
Expand All @@ -132,7 +132,7 @@ def get_conda_package(el):
return None


def check_categories(ts_categories, ts_cat):
def check_categories(ts_categories: str, ts_cat: List[str]) -> bool:
"""
Check if tool fit in ToolShed categories to keep
Expand Down Expand Up @@ -332,14 +332,14 @@ def parse_tools(repo: Repository) -> List[Dict[str, Any]]:
return tools


def format_list_column(col):
def format_list_column(col: pd.Series) -> pd.Series:
"""
Format a column that could be a list before exporting
"""
return col.apply(lambda x: ", ".join([str(i) for i in x]))
return col.apply(lambda x: ", ".join(str(i) for i in x))


def export_tools(tools: List[Dict], output_fp: str, format_list_col=False) -> None:
def export_tools(tools: List[Dict], output_fp: str, format_list_col: bool = False) -> None:
"""
Export tool metadata to tsv output file
Expand Down
1 change: 1 addition & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[mypy]
check_untyped_defs = True
disallow_untyped_defs = True
ignore_missing_imports = True
pretty = True
no_implicit_optional = True
Expand Down

0 comments on commit 88c02a3

Please sign in to comment.