False positive with attrs converter
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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: https://github.com/python/mypy/issues/5313
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Python reproducer with the reported mypy version or latest master, focusing on the attrs converter and generic-parameter inference. The work is done when the example produces no type-checking errors while preserving the declared FrozenSet[Text] type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100