Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up typing of layout.py #129

Open
goodmami opened this issue Nov 12, 2023 · 0 comments
Open

Clean up typing of layout.py #129

goodmami opened this issue Nov 12, 2023 · 0 comments
Labels
maintenance Improvements to project health

Comments

@goodmami
Copy link
Owner

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)
@goodmami goodmami added the maintenance Improvements to project health label Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Improvements to project health
Projects
None yet
Development

No branches or pull requests

1 participant