Skip to content

False positive with attrs converter #8625

Open
@tsx

Description

@tsx

Looks like mypy can't infer generic parameter properly when used in attrs converter.

from attr import attrs, attrib
from typing import FrozenSet, Text


@attrs
class Test(object):
    values = attrib(type=FrozenSet[Text], converter=frozenset)


Test(values={'a'})

Actual: reporting error

error: Argument 1 to <set> has incompatible type "str"; expected "_T"

Expected: no errors.

mypy version 0.770, python 3.5.2, no flags are used.
Latest master has basically the same error message except generic param has a different name:

error: Argument 1 to <set> has incompatible type "str"; expected "_T_co"

Possibly related: #5313

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions