mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
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:
committed by
Jelle Zijlstra
parent
ee5e3affe1
commit
2a115b1714
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user