seanbreckenridge / google_takeout_parser

A library/CLI tool to parse data out of your Google Takeout (History, Activity, Youtube, Locations, etc...)
https://pypi.org/project/google-takeout-parser/
MIT License
79 stars 14 forks source link

v0.1.4: bump cachew version,drop py3.7 support #46

Closed seanbreckenridge closed 1 year ago

seanbreckenridge commented 1 year ago

@karlicoss hmm, not sure if something changed with how cachew handles it sources, I think these should still work, but its saying it expects (what I think is ) (*args, **kwargs) functions instead of just any function

google_takeout_parser/merge.py:37: error: Argument "cache_path" to "cachew" has incompatible type "Callable[[list[str | Path]], str]"; expected
"Path | str | Callable[[VarArg(<nothing>), KwArg(<nothing>)], Path | str] | None"  [arg-type]
        cache_path=_cache_path,
                   ^~~~~~~~~~~
google_takeout_parser/merge.py:38: error: Argument "depends_on" to "cachew" has incompatible type "Callable[[list[str | Path]], str]"; expected
"Callable[[VarArg(<nothing>), KwArg(<nothing>)], str]"  [arg-type]
        depends_on=_depends_on,
                   ^~~~~~~~~~~

For this function:

def _cache_path(_takeout_paths: List[PathIsh]) -> str:
    """
    Cache path for the merged takeout
    """
    return str(takeout_cache_path / "_merged_takeouts")

def _depends_on(pths: List[PathIsh]) -> str:
    return str(list(sorted([str(p) for p in pths])))

# Note: only used for this module, HPI caches elsewhere
@cachew(
    cache_path=_cache_path,
    depends_on=_depends_on,
    force_file=True,
    logger=logger,
)
def cached_merge_takeouts(takeout_paths: List[PathIsh]) -> CacheResults:
    """
karlicoss commented 1 year ago

Hmm, type checking should be handled by this code during mypy https://github.com/karlicoss/cachew/blob/f71a505dcec07e2ad5b97c172882948b5f4429e9/src/cachew/__init__.py#L99 But don't think I changed anything recently. Wonder what happens for other python versions?

seanbreckenridge commented 1 year ago

Alright, thanks for confirming

Will see if I can figure it out