Skip to content

Indicate that float() accepts Real objects #1434

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

Merged
merged 1 commit into from
Jun 24, 2017

Conversation

eddiejessup
Copy link
Contributor

This contradicts CPython, in Lib/numbers.py, because Real does not
actually inherit from SupportsFloat. But it suppresses errors from
mypy when passing sub-classes like fractions.Fraction to float().

This contradicts CPython, in `Lib/numbers.py`, because `Real` does not
actually inherit from `SupportsFloat`. But it suppresses errors from
mypy when passing sub-classes like `fractions.Fraction` to `float()`.
@JelleZijlstra JelleZijlstra merged commit 2a115b1 into python:master Jun 24, 2017
@JelleZijlstra
Copy link
Member

Thanks!

@gvanrossum
Copy link
Member

This seems very ad-hoc. Why not add SupportsComplex to the Complex class? Also, many place that support float don't declare SupportsFloat -- we really won't get anything near correct coverage of these issues until we have Protocols (PEP 544).

@eddiejessup
Copy link
Contributor Author

@gvanrossum I basically agree, it was a slightly selfish change for my own convenience, to let me use fractions.Fraction. But I do think if any float()-able class deserves an ad-hoc fix, it's Real.

But I know basically nothing about mypy, so if this should be reverted I've no problem with it.

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

Successfully merging this pull request may close these issues.

3 participants