nd the Decimal definition I’m finding says:
class Decimal(object):
yet
print(issubclass(Decimal,Number))
returns True.
From: Paul Bryan
Date: Monday, February 6, 2023 at 9:25 AM
To: Weatherby,Gerard , dn
, 'Python'
Subject: Re: Typing Number, PyCharm
*** Attention: This is an ext
On Mon, 2023-02-06 at 12:11 +, Weatherby,Gerard wrote:
> On the one hand, it is a well-known type, so it should be
> recognizable to users of an API. On the other hand, Number is
> entirely abstract, so it doesn’t provide useful type checking for the
> implementation; I had to add # noinspecti
uble(value: Numeric):
if isinstance(value, Numeric):
return 2 * value
raise ValueError(f"{value} of {type(value)} is not Numeric")
works (>= 3.10)
From: dn
Date: Sunday, February 5, 2023 at 2:54 PM
To: Weatherby,Gerard , 'Python'
Subject: Re: Typing Number,
No @Gerard, YOU weren't missing anything: since posting, have upgraded
PyCharm to 2022.3.2 and the complaints about 'Method 5' have
disappeared. Evidently a PyCharm issue!
Which alters the top-line question to: is numbers.Number the preferred
type-hint when multiple numeric types are to be acc
dn,
I’m missing something here. Method 5 seems to work fine in PyCharm. I’m
interpreting your statement as:
from fractions import Fraction
from numbers import Number
def double(value: Number):
if isinstance(value, Number):
# noinspection PyTypeChecker
return 2 * value
r