Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support attr converters with new semantic analyzer #6438

Closed
ilevkivskyi opened this issue Feb 19, 2019 · 3 comments · Fixed by #7096
Closed

Support attr converters with new semantic analyzer #6438

ilevkivskyi opened this issue Feb 19, 2019 · 3 comments · Fixed by #7096
Assignees
Labels
priority-0-high semantic-analyzer Problems that happen during semantic analysis topic-attrs topic-plugins The plugin API and ideas for new plugins

Comments

@ilevkivskyi
Copy link
Member

This is a follow up for #6435

The attrs plugin does some tricky things to support converters, in particular although the plugin is called during semantic analysis, it look like some parts belong to type checking. In particular, we need to know analyzed types of overloaded functions while still semantically analyzing top levels, which is especially tricky with the new semantic analyzer.

See also testAttrsUsingBadConverter.

@ilevkivskyi ilevkivskyi added priority-1-normal topic-plugins The plugin API and ideas for new plugins topic-attrs semantic-analyzer Problems that happen during semantic analysis labels Feb 19, 2019
@danie1k
Copy link

danie1k commented Mar 18, 2019

I've just ran with an issue with converter. Just a sample piece of code:

from distutils.version import LooseVersion
import attr

@attr.s
class Manifest:
    version: LooseVersion = attr.ib(converter=LooseVersion, default='1.0')

And the output from mypy:

tst.py:6: error: Incompatible types in assignment (expression has type "str", variable has type "LooseVersion")

@ilevkivskyi
Copy link
Member Author

@danie1k your problem is unrelated to this issue and is a duplicate of python-attrs/attrs#518

@danie1k
Copy link

danie1k commented Mar 18, 2019

@ilevkivskyi Thanks! 👍
I didn't thought about searching attrs issues in this case.

@JukkaL JukkaL self-assigned this Jun 28, 2019
JukkaL added a commit that referenced this issue Jun 28, 2019
This is a hacky fix to better handle overloaded function during
semantic analysis. The original approach is not very clean so this
doesn't make this worse.

Fixes #6438.
JukkaL added a commit that referenced this issue Jun 28, 2019
This is a hacky fix to better handle overloaded functions during
semantic analysis. The original approach is not very clean so this
doesn't make this worse, arguably.

Fixes #6438.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-0-high semantic-analyzer Problems that happen during semantic analysis topic-attrs topic-plugins The plugin API and ideas for new plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants