You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from typing import Generic, List, Optional, TypeVar
Q = TypeVar("Q")
T = TypeVar("T", bound="RequestWrapper")
class RequestWrapper(Generic[Q]):
@classmethod
def valid(cls, reqs):
# type: (List[T]) -> List[T]
pass
class _ConcreteRequestWrapper(RequestWrapper[int]):
pass
def test(valid_reqs):
# type: (List[_ConcreteRequestWrapper]) -> None
_ConcreteRequestWrapper.valid(valid_reqs)
This produces an error in test: error: Argument 1 to "valid" of "RequestWrapper" has incompatible type "List[_ConcreteRequestWrapper]"; expected "List[<nothing>]"
This one is pretty bad actually. I understand why this happens: bind_self() just always binds the first type variable, but instead it should bind only variable(s) that appear in the self-type. I have a decent quick-fix, but I want to spend a bit more time maybe I will find a more principled fix for this while I am at it.
* Moves TypeVarExtractor to typeops.py
* Infers and applies all and only type variables that appear in an explicit self type (instead of just always the first one as currently)
Fixes#7925
Distilled from an issue in S:
This produces an error in
test
:error: Argument 1 to "valid" of "RequestWrapper" has incompatible type "List[_ConcreteRequestWrapper]"; expected "List[<nothing>]"
Looks like this was introduced in #7860.
The text was updated successfully, but these errors were encountered: