-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Adds mypy annotations for templatetags #3422
base: main
Are you sure you want to change the base?
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 |
Push ovrtyrmwkoxu
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
*args
and 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