Skip to content

Regression involving generic class methods #7925

Closed
@msullivan

Description

@msullivan

Distilled from an issue in S:

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>]"

Looks like this was introduced in #7860.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions