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 skip_empty as decorator #45

Open
bh2smith opened this issue Nov 18, 2022 · 0 comments
Open

Add skip_empty as decorator #45

bh2smith opened this issue Nov 18, 2022 · 0 comments
Labels

Comments

@bh2smith
Copy link
Collaborator

    this actually works perfectly for python >= 3.10
    # Decorator to skip write on empty data sets.
    # TODO - this cool decorator only works for python >= 3.10
    # @staticmethod
    def _skip_empty(write_like: WriteLikeSignature) -> WriteLikeSignature:
        def wrapper(
            self: FileIO, data: List[DuneRecord], name: str, ftype: FileType
        ) -> None:
            if len(data) == 0:
                logger.info(f"Nothing to write to {name}... skipping")
                return
            write_like(self, data, name, ftype)
    
        return wrapper

Unfortunately it fails for any earlier version with

TypeError: 'staticmethod' object is not callable

Here is an issue about it:

https://bugs.python.org/issue43682

Originally posted by @bh2smith in #37 (comment)

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

No branches or pull requests

1 participant