Clean up typing of layout.py
- Dominant language
- Python
- Stars
- 151
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
`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`)
Contributor guide
Research direction
Start in layout.py by reviewing the unannotated non-public functions and _process_epigraph(), then inspect tree.py for assumptions about non-empty trees. Check how the empty graph () and epigraphical data are represented, and verify that the relevant functions and Node types are consistently checked for these cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100