Skip to content

Conversation

@sobolevn
Copy link
Member

I am not 100% sure that this is correct though.

Closes #12033

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

steam.py (https://github.com/Gobot1234/steam.py)
- steam/ext/commands/commands.py:744: error: Overloaded function implementation cannot produce return type of signature 2  [misc]
- steam/ext/commands/commands.py:813: error: Overloaded function implementation cannot produce return type of signature 2  [misc]
- steam/ext/commands/commands.py:919: error: Overloaded function implementation cannot produce return type of signature 2  [misc]
- steam/ext/commands/commands.py:986: error: Overloaded function implementation cannot produce return type of signature 2  [misc]

@Akuli
Copy link
Contributor

Akuli commented Jan 29, 2022

This reproduces the problem without @final:

from typing import Generic, Any, TypeVar, Callable
from typing_extensions import ParamSpec

_P = ParamSpec("_P")
_F = TypeVar("_F", bound=Callable[..., Any])

def f(x: _F) -> _F: pass

@f
class OnlyParamSpec(Generic[_P]):
    pass

It seems to me that a correct fix would require more work. Currently is_callable_compatible() solves and substitutes type variables, if there are any. Maybe it should also replace ParamSpecs with something very permissive, e.g. Callable[..., Any]? Maybe this should be fixed in unify_generic_callable(), the function that solves and substitutes TypeVars? Even if we ignore all this, we should at least preserve the symmetry when allow_partial_overlap=True is given.

(I haven't ever contributed anything non-trivial to mypy, but I have lately poked around mypy with pdb a bit)

@sobolevn
Copy link
Member Author

sobolevn commented Feb 6, 2022

Closing in favor of #12096

@sobolevn sobolevn closed this Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@final and ParamSpec

2 participants