From fb46fb1362ce1fe601de288f02329949d1f6bf8f Mon Sep 17 00:00:00 2001 From: Elliot Marsden Date: Sat, 24 Jun 2017 12:50:53 +0200 Subject: [PATCH] Indicate that `float()` accepts `Real` objects 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()`. --- stdlib/2and3/numbers.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2and3/numbers.pyi b/stdlib/2and3/numbers.pyi index e4f7603e62f8..2a3f493e229b 100644 --- a/stdlib/2and3/numbers.pyi +++ b/stdlib/2and3/numbers.pyi @@ -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