Closed bh2smith closed 1 year ago
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:
This will look a lot like the write method, but CSVs will require special treatment (so we don't add the column headers again).
Also want a @skip_empty decorator on
_write
and_append
Something like this: but I couldn't get the types right: