Skip to content

Commit

Permalink
Add explicit exports and sort with ruff --preview (#215)
Browse files Browse the repository at this point in the history
This PR adds explicit `__all__` to some of the top level packages and
runs ruff check with preview mode enabled to sort the `__all__` in
existing modules
  • Loading branch information
cthoyt authored Nov 17, 2024
1 parent da8ca39 commit 41248d3
Show file tree
Hide file tree
Showing 42 changed files with 279 additions and 126 deletions.
93 changes: 81 additions & 12 deletions src/pyobo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""A python package for handling and generating OBO."""

from .api import ( # noqa: F401
from .api import (
get_alts_to_id,
get_ancestors,
get_children,
Expand All @@ -20,6 +20,7 @@
get_id_synonyms_mapping,
get_id_to_alts,
get_ids,
get_metadata,
get_name,
get_name_by_curie,
get_name_id_mapping,
Expand All @@ -43,26 +44,94 @@
has_ancestor,
is_descendent,
)
from .getters import get_ontology # noqa: F401
from .identifier_utils import normalize_curie # noqa: F401
from .normalizer import OboNormalizer, ground # noqa: F401
from .obographs import parse_results_from_obo # noqa: F401
from .plugins import ( # noqa: F401
from .getters import get_ontology
from .normalizer import OboNormalizer, ground
from .obographs import parse_results_from_obo
from .plugins import (
has_nomenclature_plugin,
iter_nomenclature_plugins,
run_nomenclature_plugin,
)
from .reader import from_obo_path, from_obonet # noqa: F401
from .struct import Obo, Reference, Synonym, SynonymTypeDef, Term, TypeDef # noqa: F401
from .utils.path import ensure_path # noqa: F401
from .version import get_version # noqa: F401
from .xrefdb.canonicalizer import ( # noqa: F401
from .reader import from_obo_path, from_obonet
from .struct import Obo, Reference, Synonym, SynonymTypeDef, Term, TypeDef
from .utils.path import ensure_path
from .version import get_version
from .xrefdb.canonicalizer import (
Canonicalizer,
get_equivalent,
get_priority_curie,
)
from .xrefdb.sources import ( # noqa: F401
from .xrefdb.sources import (
has_xref_plugin,
iter_xref_plugins,
run_xref_plugin,
)

__all__ = [
"Canonicalizer",
"Obo",
"OboNormalizer",
"Reference",
"Synonym",
"SynonymTypeDef",
"Term",
"TypeDef",
"ensure_path",
"from_obo_path",
"from_obonet",
"get_alts_to_id",
"get_ancestors",
"get_children",
"get_definition",
"get_descendants",
"get_equivalent",
"get_filtered_properties_df",
"get_filtered_properties_mapping",
"get_filtered_properties_multimapping",
"get_filtered_relations_df",
"get_filtered_xrefs",
"get_graph",
"get_hierarchy",
"get_id_definition_mapping",
"get_id_multirelations_mapping",
"get_id_name_mapping",
"get_id_species_mapping",
"get_id_synonyms_mapping",
"get_id_to_alts",
"get_ids",
"get_metadata",
"get_name",
"get_name_by_curie",
"get_name_id_mapping",
"get_obsolete",
"get_ontology",
"get_primary_curie",
"get_primary_identifier",
"get_priority_curie",
"get_properties",
"get_properties_df",
"get_property",
"get_relation",
"get_relation_mapping",
"get_relations_df",
"get_species",
"get_sssom_df",
"get_subhierarchy",
"get_synonyms",
"get_typedef_df",
"get_version",
"get_xref",
"get_xrefs",
"get_xrefs_df",
"ground",
"ground",
"has_ancestor",
"has_nomenclature_plugin",
"has_xref_plugin",
"is_descendent",
"iter_nomenclature_plugins",
"iter_xref_plugins",
"parse_results_from_obo",
"run_nomenclature_plugin",
"run_xref_plugin",
]
67 changes: 58 additions & 9 deletions src/pyobo/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""High-level API for accessing content."""

from .alts import ( # noqa: F401
from .alts import (
get_alts_to_id,
get_id_to_alts,
get_primary_curie,
get_primary_identifier,
)
from .hierarchy import ( # noqa: F401
from .hierarchy import (
get_ancestors,
get_children,
get_descendants,
Expand All @@ -15,8 +15,8 @@
has_ancestor,
is_descendent,
)
from .metadata import get_metadata # noqa: F401
from .names import ( # noqa: F401
from .metadata import get_metadata
from .names import (
get_definition,
get_id_definition_mapping,
get_id_name_mapping,
Expand All @@ -28,28 +28,77 @@
get_obsolete,
get_synonyms,
)
from .properties import ( # noqa: F401
from .properties import (
get_filtered_properties_df,
get_filtered_properties_mapping,
get_filtered_properties_multimapping,
get_properties,
get_properties_df,
get_property,
)
from .relations import ( # noqa: F401
from .relations import (
get_filtered_relations_df,
get_graph,
get_id_multirelations_mapping,
get_relation,
get_relation_mapping,
get_relations_df,
)
from .species import get_id_species_mapping, get_species # noqa: F401
from .typedefs import get_typedef_df # noqa: F401
from .xrefs import ( # noqa: F401
from .species import get_id_species_mapping, get_species
from .typedefs import get_typedef_df
from .xrefs import (
get_filtered_xrefs,
get_sssom_df,
get_xref,
get_xrefs,
get_xrefs_df,
)

__all__ = [
"get_alts_to_id",
"get_ancestors",
"get_children",
"get_definition",
"get_descendants",
"get_equivalent",
"get_filtered_properties_df",
"get_filtered_properties_mapping",
"get_filtered_properties_multimapping",
"get_filtered_relations_df",
"get_filtered_xrefs",
"get_graph",
"get_hierarchy",
"get_id_definition_mapping",
"get_id_multirelations_mapping",
"get_id_name_mapping",
"get_id_species_mapping",
"get_id_synonyms_mapping",
"get_id_to_alts",
"get_ids",
"get_metadata",
"get_name",
"get_name_by_curie",
"get_name_id_mapping",
"get_obsolete",
"get_ontology",
"get_primary_curie",
"get_primary_identifier",
"get_priority_curie",
"get_properties",
"get_properties_df",
"get_property",
"get_relation",
"get_relation_mapping",
"get_relations_df",
"get_species",
"get_sssom_df",
"get_subhierarchy",
"get_synonyms",
"get_typedef_df",
"get_version",
"get_xref",
"get_xrefs",
"get_xrefs_df",
"has_ancestor",
"is_descendent",
]
2 changes: 1 addition & 1 deletion src/pyobo/api/alts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from ..utils.path import prefix_cache_join

__all__ = [
"get_id_to_alts",
"get_alts_to_id",
"get_id_to_alts",
"get_primary_curie",
"get_primary_identifier",
]
Expand Down
6 changes: 3 additions & 3 deletions src/pyobo/api/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from ..struct.reference import Reference

__all__ = [
"get_ancestors",
"get_children",
"get_descendants",
"get_hierarchy",
"get_subhierarchy",
"get_descendants",
"get_ancestors",
"has_ancestor",
"is_descendent",
"get_children",
]


Expand Down
12 changes: 6 additions & 6 deletions src/pyobo/api/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
from ..utils.path import prefix_cache_join

__all__ = [
"get_name",
"get_name_by_curie",
"get_ids",
"get_id_name_mapping",
"get_name_id_mapping",
"get_definition",
"get_id_definition_mapping",
"get_synonyms",
"get_id_name_mapping",
"get_id_synonyms_mapping",
"get_ids",
"get_name",
"get_name_by_curie",
"get_name_id_mapping",
"get_obsolete",
"get_synonyms",
]

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions src/pyobo/api/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from ..utils.path import prefix_cache_join

__all__ = [
"get_properties_df",
"get_filtered_properties_df",
"get_filtered_properties_mapping",
"get_filtered_properties_multimapping",
"get_property",
"get_properties",
"get_properties_df",
"get_property",
]

logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions src/pyobo/api/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
from ..utils.path import prefix_cache_join

__all__ = [
"get_relations_df",
"get_filtered_relations_df",
"get_graph",
"get_id_multirelations_mapping",
"get_relation_mapping",
"get_relation",
"get_graph",
"get_relation_mapping",
"get_relations_df",
]

# TODO get_relation, get_relations
Expand Down
4 changes: 2 additions & 2 deletions src/pyobo/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from ..utils.path import prefix_directory_join

__all__ = [
"safe_get_version",
"VersionError",
"get_version",
"get_version_pins",
"VersionError",
"safe_get_version",
]

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions src/pyobo/api/xrefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
from ..utils.path import prefix_cache_join

__all__ = [
"get_xrefs_df",
"get_filtered_xrefs",
"get_sssom_df",
"get_xref",
"get_xrefs",
"get_sssom_df",
"get_xrefs_df",
]

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/pyobo/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

__all__ = [
"download_artifacts",
"list_artifacts",
"upload_artifacts",
"upload_artifacts_for_prefix",
"list_artifacts",
]

logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions src/pyobo/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from ..constants import DATABASE_DIRECTORY

__all__ = [
"echo_df",
"directory_option",
"zenodo_option",
"echo_df",
"force_option",
"prefix_argument",
"no_strict_option",
"prefix_argument",
"zenodo_option",
]


Expand Down
2 changes: 1 addition & 1 deletion src/pyobo/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import pystow

__all__ = [
"RAW_DIRECTORY",
"DATABASE_DIRECTORY",
"RAW_DIRECTORY",
"SPECIES_REMAPPING",
]

Expand Down
2 changes: 1 addition & 1 deletion src/pyobo/getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
from .version import get_git_hash, get_version

__all__ = [
"get_ontology",
"NoBuildError",
"get_ontology",
]

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions src/pyobo/gilda_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
from pyobo.utils.io import multidict

__all__ = [
"iter_gilda_prediction_tuples",
"get_grounder",
"get_gilda_terms",
"get_grounder",
"iter_gilda_prediction_tuples",
]

logger = logging.getLogger(__name__)
Expand Down
Loading

0 comments on commit 41248d3

Please sign in to comment.