Add type annotations for screens.components subpackage#19
Open
pbugnion wants to merge 61 commits intoorder-files-by-size-diff-screenfrom
Open
Add type annotations for screens.components subpackage#19pbugnion wants to merge 61 commits intoorder-files-by-size-diff-screenfrom
pbugnion wants to merge 61 commits intoorder-files-by-size-diff-screenfrom
Conversation
Previously, this was just done in a simple tuple. That harmed readability.
This will let us render more than just the path.
This will help structure the file list, sizes and mtimes.
This allows embedding the table container in HSplits and VSplits.
Allows embedding table in {H,V}Splits.
Running mypy in project root now passes. Many of the dependencies on external libraries remain ignored.
Now that we use to_container, we don't need to have a bunch of methods that just proxy to window.
We now use mypy in strict mode on the sml_sync.screens.components subpackage.
Open
6db9504 to
11bc160
Compare
38eb083 to
cbaae62
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an attempt at introducing greater rigour in how we use mypy types. This PR is mostly supposed to be a starting point for discussions, not necessarily useful in itself.
The
sml_sync.screens.componentssubpackage now has full typechecking, including on all private methods. This subpackage heavily dependent on prompt_toolkit, which doesn't have type annotations, so I've written some stubs by just reading the code on GitHub.This exercise has lead to some tidying of import structures (we were frequently importing classes from
prompt_toolkit.layout.containersorprompt_toolkit.layout.controls, instead of directly fromprompt_toolkit.layout, for instance), so it's been somewhat beneficial for the codebase. Nevertheless, type annotations do add complexity, so I'm open to deciding we don't want these.If we do decide to merge this, we should test it in Travis.
To reproduce, run: