Mark Dickinson <dicki...@gmail.com> added the comment:

I'm actually struggling to think of situations where typing.SupportsInt would 
be useful in its current form: if I'm writing a function that wants to do a 
duck-typed acceptance of integer-like things (for example because I want my 
function to work with NumPy integers as well as plain old Python ints) then I 
want an __index__ check rather than an __int__ check. If I'm writing a function 
that allows general numeric inputs, then I'm not sure why I'd be calling 'int' 
on those inputs.

As another data point, complex supporting __int__ is a little bit of an oddity, 
since all that __int__ method does is raise a TypeError.

@Michael: are you in a position to share the use-case that motivated opening 
the issue? I'd be interested to see any concrete uses of typing.SupportsInt.

Maybe typing.SupportsIndex (or typing.UsableAsInt, or ... --- naming things is 
hard) is what we actually need?

On this particular issue: I'm not opposed to adding __int__ to 
fractions.Fraction purely for the sake of consistency, but it's not yet clear 
to me that it solves any real issue.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44547>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to