Files
nixpkgs/nixos/lib/test-script-prepend.py
Maximilian Bosch d9befc6484 nixos/test-driver: fix deprecation behavior
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.
2026-08-07 15:52:09 +02:00

3.0 KiB