fix: return "Self" from "BaseRetrying.copy"#518
Conversation
|
|
|
@jd On an unrelated note - would a PR that adds a package manager (uv seems to be a good choice nowadays) to setup a dev environment be welcome? |
Yes, if that can replace tox I'll be happy.
I'll work on that at some point, good thing. |
If you need to run multiple python environments/versions/dependency versions tox is probably the right choice, but that could instead be done in CI and mypy/ruff seem to work correctly when you specify target version, though you still can run them in CI with all python versions. |
|
I've checked with mypy, pyright and PyCharm: from tenacity import AsyncRetrying, Retrying
retrying = AsyncRetrying()
reveal_type(retrying.copy()) # note: Revealed type is "tenacity.asyncio.AsyncRetrying"
retrying_sync = Retrying()
reveal_type(retrying_sync.copy()) # note: Revealed type is "tenacity.Retrying"Pyright too: src\main.py:4:13 - information: Type of "retrying.copy()" is "AsyncRetrying"
src\main.py:7:13 - information: Type of "retrying_sync.copy()" is "Retrying"Typing extensions has section in documentation about using types in runtime: https://typing-extensions.readthedocs.io/en/latest/#runtime-use-of-types import typing
from tenacity import AsyncRetrying, Retrying
typing.get_type_hints(AsyncRetrying.copy)but is seems to fail earlier due to |

Currently
BaseRetrying.copyreturnsBaseRetrying, making reusing a "template"/base retrying object harder.Example usecase: