layout.py has at least three problems with the way its functions are typed. First, some non-public functions don't use type annotations on the signatures, so they are not checked. Fixing that reveals the other two problems:
The tree-configuring functions don't return penman.types.Node objects, but a "pre-node" object where epigraphical data is separate. A data structure is modified in-place (see _process_epigraph()) to resolve these before the final tree is returned. This could be cleaner.
Node objects are typed as Tuple[Variable, List[Branch]], but in some cases, like () as a PENMAN graph, the variable could be None. This is a special case, and when this happens the list of branches should be []. The current code assumes non-empty trees in some places (also in tree.py)
layout.py
has at least three problems with the way its functions are typed. First, some non-public functions don't use type annotations on the signatures, so they are not checked. Fixing that reveals the other two problems:penman.types.Node
objects, but a "pre-node" object where epigraphical data is separate. A data structure is modified in-place (see_process_epigraph()
) to resolve these before the final tree is returned. This could be cleaner.Node
objects are typed asTuple[Variable, List[Branch]]
, but in some cases, like()
as a PENMAN graph, the variable could beNone
. This is a special case, and when this happens the list of branches should be[]
. The current code assumes non-empty trees in some places (also intree.py
)