the.bay.news

Fallbacks for typing.overload

Discussions on Python.org
Fallbacks for typing.overload
Would an @overload-related fallback decorator that catches everything not assignable to an existing overload be feasible? For example, consider the following: from typing import overload @overload def spam(ham: int) -> str: ... @overload def spam(ham: str) -> int: ... @overload_fallback def spam(ham: Any) -> None: ... def spam(ham: int | str | bytes | bytearray) -> str | int | None: ... Then spam(b"12") would be inferred as int since (ham: bytes) is not assignable to (ham: int) or (ham: str),...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.