Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
|
oh that broke terribly didn't it. |
This comment has been minimized.
This comment has been minimized.
|
I think that the given example is not ideal. Because typevar should not even be used in this example: T = typing.TypeVar("T", bound=A)
@typing.overload
def f(a: T) -> None:
...
@typing.overload
def f(*, copy: bool = False) -> None:
...
def f(a: T = ..., *, copy: bool = False) -> None:
...Should be: @typing.overload
def f(a: A) -> None:
...
@typing.overload
def f(*, copy: bool = False) -> None:
...
def f(a: A = ..., *, copy: bool = False) -> None:
...Maybe you should also add an example, where |
|
The given example was an oversimplification of the original, which can be simplified to: import typing
import collections.abc as collections
class BaseSlashCommand:
...
BaseSlashCommandT = typing.TypeVar("BaseSlashCommandT", bound=BaseSlashCommand)
@typing.overload
def with_slash_command(command: BaseSlashCommandT, /) -> BaseSlashCommandT:
...
@typing.overload
def with_slash_command(
*, copy: bool = False
) -> collections.Callable[[BaseSlashCommandT], BaseSlashCommandT]:
...
def with_slash_command(
command: BaseSlashCommandT = ..., /, *, copy: bool = False
) -> typing.Union[BaseSlashCommandT, collections.Callable[[BaseSlashCommandT], BaseSlashCommandT]]:
...The original can be found at https://github.com/FasterSpeeding/Tanjun/blob/7edec0fa4418718343826f9c6489bd817c4a9b47/tanjun/components.py#L590-L604 (yes I know the |
|
Went through some issues that seemed partially related -- it looks like #9023 gets fixed by this too! |
Time for a quick run of mypy-primer!
|
Diff from mypy_primer, showing the effect of this PR on open source code: Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/abc.py:3139: error: Overloaded function implementation cannot satisfy signature 2 due to inconsistencies in how they use type variables [misc]
- tanjun/abc.py:3205: error: Overloaded function implementation cannot satisfy signature 2 due to inconsistencies in how they use type variables [misc]
|
|
Remade in #15320 |
Description
This fixes this following program:
This also fixes #9023.
Test Plan
I haven't added any tests yet, I plan to do that based on mypy primer output (still not sure this works...).