aisk / pick

create curses based interactive selection list in the terminal
MIT License
729 stars 63 forks source link

Setup Poetry and introduce type hints #52

Closed MaxG87 closed 2 years ago

MaxG87 commented 2 years ago

This PR will introduce Poetry as only tool to manage the project and add extensive type hints.

The part about Poetry is quite uncontroversial, since there is already an open ticket for that. Thus, this PR fixes #41.

The introduction of type hints is what brought me here. I would like to have them in another project. Unfortunately, this introduces severe complexity into the code base. I tried to mitigate this by always returning a list of selections, but the problem still remains. Since it only reflects the complexity inherent to the Picker class, I decided to proceed anyways. Some further improvements might be possible by using @overload annotations from typing, but I wanted to get some feedback before I proceed with that.

Fortunately, most of the type hint complexity affects the Picker class itself. For someone who only uses the pick function, everything is quite obvious.

I hope that this PR is helpful to you. If you feel uncomfortable about the type hint stuff, I could separate this into another PR and refine it there.

MaxG87 commented 2 years ago

I managed to simplify the type annotations a bit. Now the options_func_map is not an optional function anymore, but a mandatory with a default value. This does not affect how users interact with the framework. However, it allows to use OPTIONS_MAP_VALUE_T throughout, without having to use the default Tuple[str, int] anywhere.

wong2 commented 2 years ago

nice, I'll have a look soon

wong2 commented 2 years ago

I'd rather have this splitted to two seperate PRs

wong2 commented 2 years ago

Hi, could you please make the follow-up PR?

wong2 commented 2 years ago

Also I'm considering refactor the project with blessed https://github.com/wong2/pick/issues/58