How would people feel about making dask.bag.Bag
a generic type, so that type checkers and function signatures could include the information about what’s in a dask bag. For example
def add_lengths(bag: dask.bag.Bag[list[dict[str, Any]]]) -> dask.bag.Bag[list[dict[str, Any]]]:
return bag.map(add_length)
def add_length(item: dict[str, Any]) -> dict[str, Any]:
item["length"] = len(item["document"])
I’d be happy to write a PR for this.