mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-31 20:54:56 +00:00
We have a lot of changes in the style of
def foo(
self,
new: dt.timedelta | None = None,
old: float | None = None,
)
which is OK for cases where the API is used as
foo(old=23.5)
however for named arguments that actually falls short in the `ty`-stage:
foo(23.5)
As a workaround I flipped the order of old/new and changed the type of
`old` to accept both a timedelta and the old type, i.e.
def foo(
self,
old: float | dt.timedelta | None = None,
new: dt.timedelta | None = None,
)
and only give a deprecation warning if `old` is not of type `dt.timedelta | None`.
That way, both
foo(old=23.5)
foo(23.5)
are still accepted, at the same time, both
foo(new=timedelta(...))
foo(timedelta(...))
are OK.
3.0 KiB
3.0 KiB