Skip to content

Clean up typing of layout.py #129

@goodmami

Description

@goodmami

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenanceImprovements to project health

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions