33import itertools
44import logging
55import re
6+ from typing import Any
67
78import networkx
89
1314
1415def read_obo (
1516 path_or_file , ignore_obsolete : bool = True , encoding : str | None = "utf-8"
16- ):
17+ ) -> networkx . MultiDiGraph [ str ] :
1718 """
1819 Return a networkx.MultiDiGraph of the ontology serialized by the
1920 specified path or file.
@@ -29,7 +30,7 @@ def read_obo(
2930 ignore_obsolete : boolean
3031 When true (default), terms that are marked 'is_obsolete' will
3132 not be added to the graph.
32- encoding : str of None
33+ encoding : str or None
3334 The character set encoding to use for path_or_file when path_or_file
3435 is a path/URL. Set to None for platform-dependent locale default.
3536 """
@@ -67,7 +68,11 @@ def read_obo(
6768 return graph
6869
6970
70- def get_sections (lines ):
71+ def get_sections (
72+ lines ,
73+ ) -> tuple [
74+ list [dict [str , Any ]], list [dict [str , Any ]], list [dict [str , Any ]], dict [str , Any ]
75+ ]:
7176 """
7277 Separates an obo file into stanzas and process.
7378 Returns (typedefs, terms, instances, header) tuples
@@ -106,7 +111,7 @@ def get_sections(lines):
106111) # noqa: E501
107112
108113
109- def parse_tag_line (line ) :
114+ def parse_tag_line (line : str ) -> tuple [ str , str | None , str | None , str | None ] :
110115 """
111116 Take a line representing a single tag-value pair and parse
112117 the line into (tag, value, trailing_modifier, comment).
@@ -126,7 +131,7 @@ def parse_tag_line(line):
126131 return tag , value , trailing_modifier , comment
127132
128133
129- def parse_stanza (lines , tag_singularity ):
134+ def parse_stanza (lines , tag_singularity ) -> dict [ str , Any ] :
130135 """
131136 Returns a dictionary representation of a stanza.
132137 """
0 commit comments