Conversation
|
@bookwyrm-social/code-review would be great, I am new to using type annotations |
Do you maybe have an example of this? |
I think this is about bookwyrm/bookwyrm/utils/cache.py Lines 7 to 18 in af5f71f This can be typed more narrowly using typing.ParamSpec: from typing import Callable, Optional, ParamSpec, TypeVar
Args = ParamSpec("Args")
Ret = TypeVar("Ret")
def get_or_set(
cache_key: str,
function: Callable[Args, Ret],
*args: Args.args,
timeout: Optional[float] = None
) -> Ret:
...@mouse-reeve: you can pull this fix (and a couple other minor improvements) from this branch in my repo: mypy...dato:bookwyrm:push-ovrtyrmwkoxu. (I can also push here directly if you prefer!) With these three commits, the |
|
thank you! I think |
|
I'm going through and closing pull requests that are just too out of date. Please feel free to re-open or leave a comment if you have questions or want to revisit this ❤️ |
Description
I figured I'd try and get used to typing, so I added some typing.
One thing I haven't figured out is how to handle definitions that take
*argsand can be called with miscellaneous arguments (maybe you know, @jderuiter?).What type of Pull Request is this?
Does this PR change settings or dependencies, or break something?
Details of breaking or configuration changes (if any of above checked)
Documentation
Tests