Am 25.02.21 um 21:14 schrieb Eric Traut:
Pyright also assumes that definition order matters and evaluates each overload in turn until it finds a match.
Like mypy, pyright has a check for overlapping overloads whose return types do not match. It also reports when later overloads are "masked" by earlier overloads because their parameter lists and types overlap completely. I needed to [disable these checks](https://github.com/python/typeshed/blob/bf583da275014e07454369f4d4bf5cd91647...) when we recently added the pyright CI test for typeshed stubs because this error is reported in 13 places within typeshed.
Could you clarify what you mean by "overlap completely"? The case that spawned this was typed like this: ``` _T = TypeVar("_T") @overload def foo(x: float) -> int: ... @overload def foo(x: _T) -> _T: ... ``` which should be fine and is necessary in some places. Of course the following: ``` _T = TypeVar("_T") @overload def foo(x: _T) -> _T: ... @overload def foo(x: float) -> int: ... ``` is definitely an error we should fix in typeshed, because the second overload doesn't do anything. We already need to add `# type: ignore`s for mypy's benefit, so we can do the same for pyright and enable `reportOverlappingOverload`. Although ideally, mypy and pyright would recognize "partial" overrides like in the first case and not issue warnings. - Sebastian