Indicate that float() accepts Real objects (#1434)

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 commit is contained in:
Elliot Marsden
2017-06-24 16:55:41 +02:00
committed by Jelle Zijlstra
parent ee5e3affe1
commit 2a115b1714

View File

@@ -5,7 +5,7 @@
# Note: these stubs are incomplete. The more complex type
# signatures are currently omitted.
from typing import Any, Optional, TypeVar
from typing import Any, Optional, TypeVar, SupportsFloat
from abc import ABCMeta, abstractmethod
import sys
@@ -59,7 +59,7 @@ class Complex(Number):
if sys.version_info < (3, 0):
def __ne__(self, other: object) -> bool: ...
class Real(Complex):
class Real(Complex, SupportsFloat):
@abstractmethod
def __float__(self) -> float: ...
@abstractmethod