Skip to content

Overloaded functions and aliases not working together #8216

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

Closed
canepan opened this issue Dec 29, 2019 · 1 comment
Closed

Overloaded functions and aliases not working together #8216

canepan opened this issue Dec 29, 2019 · 1 comment
Labels
bug mypy got something wrong topic-attrs

Comments

@canepan
Copy link

canepan commented Dec 29, 2019

Please provide more information to help us understand the issue:

  • Reporting a bug
  • failing (mock) code:
class CustomType:
    myattr: str = ''

def _custom_repr(v: CustomType) -> str:
    return v.myattr

@attr.s
class MyClass(object)
    myvar: CustomType = attr.ib(repr=_custom_repr)
  • the actual output: error: No overload variant matches argument type "Callable[[Any], str]"
  • the behavior/output I expect: mypy should succeed
  • mypy 0.720
  • mypy flags: --python-version 3.6 --python-executable python3.6
  • mypy flags (from config): ignore_missing_imports = True
  • If mypy crashed with a traceback, please paste
    the full traceback below.

possibly related to: #6157 , #8092

@AlexWaygood
Copy link
Member

I tried running mypy on this snippet locally:

import attr

class CustomType:
    myattr: str = ''

def _custom_repr(v: CustomType) -> str:
    return v.myattr

@attr.s
class MyClass(object):
    myvar: CustomType = attr.ib(repr=_custom_repr)

But I could not reproduce the error with version 0.942 of mypy. So I assume that this issue is now fixed.

@AlexWaygood AlexWaygood added bug mypy got something wrong topic-attrs labels Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-attrs
Projects
None yet
Development

No branches or pull requests

2 participants