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

staticmethod return type is not inferred correctly #8181

Closed
lovasoa opened this issue Dec 19, 2019 · 1 comment
Closed

staticmethod return type is not inferred correctly #8181

lovasoa opened this issue Dec 19, 2019 · 1 comment

Comments

@lovasoa
Copy link

lovasoa commented Dec 19, 2019

  • Are you reporting a bug, or opening a feature request?
    reporting a bug
  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
class A:
    @staticmethod
    def f(x: int) -> str: raise NotImplementedError

class B(A):
    f = staticmethod(chr)

assert B().f(97) == "a"
  • What is the actual behavior/output?
asd.py:6: error: Incompatible types in assignment (expression has type "staticmethod", base class "A" defined the type as "Callable[[int], str]")
asd.py:8: error: Cannot determine type of 'f'
  • What is the behavior/output you expect?
    I think this should not raise any type error.

  • What are the versions of mypy and Python you are using?
    mypy 0.720
    Python 3.7.5

@ilevkivskyi
Copy link
Member

This is essentially a duplicate of #3482

@lovasoa lovasoa changed the title statimethod return type is not inferred correctly staticmethod return type is not inferred correctly Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants