Skip to content

Poor handling of attrs converters. #9354

Open
@alanhdu

Description

@alanhdu

When running mypy over the following file:

from typing import Sequence
import attr

@attr.s
class A:
    a: Sequence[str] = attr.ib(converter=list)
A(["a"])

I get:

$ mypy a.py
a.py:7: error: List item 0 has incompatible type "str"; expected "_T"

which is a little confusing, because str should work fine here. This is with mypy 0.782 and on Python 3.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongfalse-positivemypy gave an error on correct codetopic-attrs

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions