-
Notifications
You must be signed in to change notification settings - Fork 46
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
Feat: Actions #1349
Feat: Actions #1349
Conversation
ChatGPT sent me on so many wild goose chases, I tried: - Protocol - singledispatch - overloads and none of them worked. ChatGPT spun tales of how Mypy is incapable of detecting callables through partials, how it can't track duck typed functions, etc etc literally for a 2 character change fml
Instead of having 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the design overall :)
I think I want the 3 separate functions, at least for now. |
Feel free to ask me if I'm online :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nits.
I think it's fair to call "actions.py: the action classes, the registry and the related functions" done now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last nit...
by job he's done it
The discussion on this PR has become a bit tl;dr to follow. I will hopefully have time to look at this properly during the weekend :) |
@Akuli any update on this? I think it's in a good state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits, but otherwise LGTM
Co-authored-by: Akuli <[email protected]>
Co-authored-by: rdbende <[email protected]>
Co-authored-by: rdbende <[email protected]>
Only thing left at this point is docs IMO. Is it worth doing that before more stuff uses actions? |
def set_enabled_based_on_tab( | ||
path: str, callback: Callable[[tabs.Tab | None], bool] | ||
) -> Callable[..., None]: | ||
_menu_item_enabledness_callbacks: list[Callable[..., None]] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not super happy with this design, but I just want this merged.
First pass, here is how you would register an action that is only available for Markdown files against Paths:
I was going to have some dedicated arguments for things like filetype availability, whether or not you can use a directory or a file path, etc, but ultimately I think what makes the most sense is having a single callback that takes a list of
availability_callbacks
, idea being these callbacks will be executed in order, and if any returnFalse
, the action is not available. I think that creating helpers for this will be extremely flexible, composable, and dev friendly.Thoughts on how it is so far?
Fixes #1341