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

feat: async filter interface #115

Merged
merged 2 commits into from
Apr 16, 2023
Merged

feat: async filter interface #115

merged 2 commits into from
Apr 16, 2023

Conversation

jg-rp
Copy link
Owner

@jg-rp jg-rp commented Apr 15, 2023

This pull requests adds support for async filters via an optional filter_async method on class-based filters.

When rendered in an async context, the filter_async method of the following filter will be awaited, instead of calling __call__.

class SomeFilter:
    """A mock class-based filter implementing the async filter interface."""

    def __call__(self, val: object) -> str:
        return "Hello, " + str(val)

    async def filter_async(self, val: object) -> str:
        return "Goodbye, " + str(val)

@jg-rp jg-rp marked this pull request as ready for review April 15, 2023 07:17
@jg-rp jg-rp merged commit ffc34cb into main Apr 16, 2023
@jg-rp jg-rp deleted the async-filters branch April 16, 2023 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant