Skip to content

Commit

Permalink
Add assertions for version to fix mypy linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nanglo123 committed Aug 13, 2024
1 parent 5d93d6c commit cd412ca
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/pyobo/cli/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def ancestors(prefix: str, identifier: str, force: bool, version: Optional[str])
"""Look up ancestors."""
curies = get_ancestors(prefix=prefix, identifier=identifier, force=force, version=version)
for curie in sorted(curies or []):
click.echo(f"{curie}\t{get_name_by_curie(curie, version)}")
click.echo(f"{curie}\t{get_name_by_curie(curie, version=version)}")


@lookup.command()
Expand All @@ -295,7 +295,7 @@ def descendants(prefix: str, identifier: str, force: bool, version: Optional[str
"""Look up descendants."""
curies = get_descendants(prefix=prefix, identifier=identifier, force=force, version=version)
for curie in sorted(curies or []):
click.echo(f"{curie}\t{get_name_by_curie(curie, version)}")
click.echo(f"{curie}\t{get_name_by_curie(curie, version=version)}")


@lookup.command()
Expand Down
1 change: 1 addition & 0 deletions src/pyobo/sources/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def get_mesh_category_curies(
"""
if version is None:
version = get_version("mesh")
assert version is not None
tree_to_mesh = get_tree_to_mesh_id(version=version)
rv = []
for i in range(1, 100):
Expand Down
3 changes: 2 additions & 1 deletion src/pyobo/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

logger = logging.getLogger(__name__)

VersionHint = Union[None, str, Callable[[], str]]
VersionHint = Union[None, str, Callable[[], Optional[str]]]

requests_ftp.monkeypatch_session()

Expand All @@ -46,6 +46,7 @@ def prefix_directory_join(
logger.info("[%s] got version %s", prefix, version)
elif not isinstance(version, str):
raise TypeError(f"Invalid type: {version} ({type(version)})")
assert version is not None
version = cleanup_version(version, prefix=prefix)
if version is not None and "/" in version:
raise ValueError(f"[{prefix}] Can not have slash in version: {version}")
Expand Down
1 change: 1 addition & 0 deletions src/pyobo/xrefdb/sources/pubchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def get_pubchem_mesh_df(version: Optional[str] = None) -> pd.DataFrame:
"""Get PubChem Compound-MeSH xrefs."""
if version is None:
version = get_version("pubchem")
assert version is not None
cid_mesh_url = _get_pubchem_extras_url(version, "CID-MeSH")
return pd.DataFrame(
[
Expand Down

0 comments on commit cd412ca

Please sign in to comment.