Skip to content

List is incompatible with Sequence in parameter #7992

@isac322

Description

@isac322
  • Are you reporting a bug, or opening a feature request?

A Bug maybe?

  • Please insert below the code you are checking with mypy

test.py:

from typing import Sequence, List

class A:
    def test(self, t: Sequence[int]) -> Sequence[str]:
        pass

class B(A):
    def test(self, t: List[int]) -> List[str]:
        pas
  • What is the actual output?

mypy test.py

test.py:8: error: Argument 1 of "test" is incompatible with supertype "A"; supertype defines the argument type as "Iterable[int]"
Found 1 error in 1 file (checked 1 source file)
  • What is the output you expect?

mypy test.py

Success: no issues found in 1 source file
  • What are the versions of mypy and Python you are using?

    • mypy: 0.740
    • python: 2.7.13 and 3.7.6 (tested both)
  • Do you see the same issue after installing mypy from Git master?

Yes (on 989626a)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions