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

float not understood as numbers.Number #7375

Closed
jordan-schneider opened this issue Aug 20, 2019 · 1 comment
Closed

float not understood as numbers.Number #7375

jordan-schneider opened this issue Aug 20, 2019 · 1 comment

Comments

@jordan-schneider
Copy link

jordan-schneider commented Aug 20, 2019

Please provide more information to help us understand the issue:

  • 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.
import numbers

a: float = 5.0
print(isinstance(a, numbers.Number))  # True

def f(a: float) -> numbers.Number:
    return a  # Incompatible return value type (got "float", expected "Number")
  • What is the actual behavior/output?
    Mypy reports the error "Incompatible return value type (got "float", expected "Number")".
  • What is the behavior/output you expect?
    I expect mypy to report no errors.
  • What are the versions of mypy and Python you are using?
    mypy 0.660
    Python 3.6.8
    Do you see the same issue after installing mypy from Git master?
    Yes.
  • What are the mypy flags you are using? (For example --strict-optional)
    None.

I'm slightly unclear if this is really a bug because I don't really understand what numbers is doing but isinstance() returns true, so I would expect the above code to be fine.

Thanks!

@ilevkivskyi
Copy link
Member

This a (yet another) duplicate of #3186

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