Reconsider constraints involving parameter specifications
- Fixes https://github.com/python/mypy/issues/15037
- Fixes https://github.com/python/mypy/issues/15065
- Fixes https://github.com/python/mypy/issues/15073
- Fixes https://github.com/python/mypy/issues/15388
- Fixes https://github.com/python/mypy/issues/15086
Yet another part of https://github.com/python/mypy/pull/14903 that's finally been extracted!
Diff from mypy_primer, showing the effect of this PR on open source code:
discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/core.py:1721: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
+ discord/ext/commands/core.py:1791: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
Mypy primer diff looks right!
Diff from mypy_primer, showing the effect of this PR on open source code:
discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/core.py:1729: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
+ discord/ext/commands/core.py:1799: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
Diff from mypy_primer, showing the effect of this PR on open source code:
discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/core.py:1729: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
+ discord/ext/commands/core.py:1799: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
Fake error
Decently close to coming up with a reliable way to trigger this logic, but funnily enough I found a paramspec bug 👻
Just marking it here before I forget:
from typing import Generic, Callable, Union
from typing_extensions import ParamSpec, Concatenate
P = ParamSpec("P")
P1 = ParamSpec("P1")
class Tester(Generic[P1]):
@staticmethod
def test_something(x: Callable[P, None]) -> Tester[P]: ... # type: ignore[empty-body]
@staticmethod
def test_concatenate(x: Callable[P, None]) -> Tester[Concatenate[int, P]]: ... # type: ignore[empty-body]
def func(
action: Callable[P, None],
) -> None:
job = Tester.test_concatenate(action) if True else Tester.test_something(action)
reveal_type(job)
err, actually i'm decently sure that's just inference being annoying :(
Diff from mypy_primer, showing the effect of this PR on open source code:
graphql-core (https://github.com/graphql-python/graphql-core): typechecking got 1.05x slower (315.7s -> 332.7s)
(Performance measurements are based on a single noisy sample)
discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/core.py:1729: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
+ discord/ext/commands/core.py:1799: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
Diff from mypy_primer, showing the effect of this PR on open source code:
discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/core.py:1729: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
+ discord/ext/commands/core.py:1799: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
Hi, bumping for @hauntsaninja or maybe @JukkaL.
I am going to revert this. IMO this is just a bunch of more hacks to compensate for older hacks. Current ParamSpec support is quite foundationally broken. That needs to be addressed first.
I do think this isn't necessarily hacky -- I basically updated the code directly based on how I expect things to work out.... but I understand that ParamSpec support as a whole is hacky so... Makes sense
(I'm still surprised that this solved any issues at all; I made this PR because things were being weird)
Yes, right, this doesn't really adds new hacks. I think I have an idea how to make ParamSpec a bit more principled. I am going to include some part of cleanups in coming inference PR (just because I was touching related code). Then I will make a separate second PR. I see you are interested in this topic. I will keep you posted on Discord.