[false positive] "Unsupported converter" raised for methods
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
mypy reports an error when a method is used as an attr converter.
To Reproduce
import attr
@attr.s(auto_attribs=True, slots=True)
class UpperString():
"""Uppercase string."""
value: str = attr.ib(converter=str.upper)
Expected Behavior
str.upper is a named method. It takes a str (self, usually) and returns a `str.
Actual Behavior
"Unsupported converter, only named functions and types are currently supported"
Your Environment
- Mypy version used: 0.910 (latest)
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: latest
- Operating system and version: all
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
Reproduce the example with mypy 0.910 and inspect how attr converter expressions are classified, focusing on why the named method str.upper is rejected. Done means the example type-checks without the false positive and a regression test covers method converters.
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
- 35/100