-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve numbers #464
Improve numbers #464
Conversation
@matthiaskramm If you are okay with adding numbers to the pytype blacklist, I'm okay with this change and you can merge it. @tharvik Thanks for adding SupportsComplex to the typing.pyi stubs! |
@matthiaskramm to be precise, the issue is occuring for |
Can we make |
If you can update the PR I can test it. I'm not sure how easy it will be to
make builtins depend on numbers, nor if there are other traps waiting. I
also worry that we'd then want to do the same for float/Real, int/Integral,
and Fraction/Rational, and I'd worry about the big cycle of dependencies
that might cause. But maybe it's not so bad. Try it!
|
Played around with it, but for this to work, you'd have to make All in all, it seems less painful to just use the |
A small experiment indicates that |
8f6b4de
to
853b2d6
Compare
d61c0bc
to
5b4ba60
Compare
Hey @tharvik -- I haven't followed this PR at all -- can you summarize why it is failing with mypy? |
@gvanrossum I'm trying to have builtins The issue that I'm having is that, correct me if I'm wrong, each class from |
Hm, that's strange. Integral.add should accept a Real, the result will And int.add does accept float (at least conceptually), again returning However I don't think anyone uses these ABCs, so perhaps it's not so |
@gvanrossum We discussed this back in 2013 before PEP 484 and I believe the conclusion was that the classes in For example, Basically none of the functions in stdlib stubs accept Another reason I don't like @tharvik Do you have a concrete use case that this solves? I'd like to see some non-trivial example code that is improved by using |
(This topic comes up pretty frequently and is quite non-trivial -- maybe we should discuss this in the typing issue tracker, make a formal decision and write it up in PEP 484.) |
Yeah, sounds like a good topic for typing. Please get it started!
|
Further discussion here: python/typing#272 |
@JukkaL I don't find the codebase where I saw it,. For now, let's close it, I'll let you know if I come across some code really using it. |
https://docs.python.org/3/library/numbers.html
# type: ignore
commentsSupportsComplex
to typing.py in py2