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

Add a @finalize decorator for functions to be run on the result of all subroutines. #140

Open
bckohan opened this issue Nov 15, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@bckohan
Copy link
Member

bckohan commented Nov 15, 2024

For symmetry with @initialize

Check - not redundant with result_callback on an initialize?

@bckohan bckohan added the enhancement New feature or request label Nov 15, 2024
@bckohan bckohan self-assigned this Nov 15, 2024
@bckohan
Copy link
Member Author

bckohan commented Nov 15, 2024

You can currently do something like this, but its very awkward:

class Command(TyperCommand):

    def finalize(self, **kwargs):
        pass

    @initialize(result_callback=finalize)
    def init(self):
        pass

    @command()
    def cmd(self):
        return self

Or this for chainable commands:

class Command(TyperCommand, chain=True):

    @staticmethod
    def finalize(result, **kwargs):
        self = result[0]

    @initialize(result_callback=finalize)
    def init(self):
        pass

    @command()
    def cmd(self):
        return self

Would prefer to be able to do something like:

class Command(TyperCommand, chain=True|False):

    @finalize()
    def finalize(self, results):
        pass

    @initialize()
    def init(self):
        pass

    @command():
    def cmd(self):
        return self

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant