[issue47079] Integral.denominator shouldn't return an int

2022-03-27 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> not a bug stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue47079] Integral.denominator shouldn't return an int

2022-03-27 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: > It does not satisfy your assumptions in msg416056. Yes, but does it fits to assumptions of the numbers module? To be fair, there is even no requirement, that numerator/denominator are Integral instances (#25619 address also this). BTW, it seems, the

[issue47079] Integral.denominator shouldn't return an int

2022-03-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It does not satisfy your assumptions in msg416056. So you have either correct your assumptions, or change the implementation of __add__, or change the implementation of denominator in your code. -- ___ Python

[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: > Integral.__add__ is an abstract method, so it is a problem of your > implementation. But such an implementation does satisfy all assumptions of the Integral abc, correct? -- ___ Python tracker

[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Integral.__add__ is an abstract method, so it is a problem of your implementation. -- ___ Python tracker ___

[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: > The module documentation should not contain all historical reasons of every > design decision. Sure. But, for example, there should be an explanation of why foo+foo.denominator could produce an error for a valid implementation of the Integral abc.

[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The module documentation should not contain all historical reasons of every design decision. If you are interesting why something was done in one way or another, do your research. One of reasons is that type(self) not always have a constructor with

[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: > There is no "why". Why not? Apparently, this is a documentation error, at least. (And I doubt there are tests for default methods.) > If you are interesting "why", try to search old archives for the history of > creating that module. Thanks.

[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There is no "why". There is a fact that there is no such constrain. Adding a new constrain may break existing code. If you want to add a constrain, add it in you code. If you are interesting "why", try to search old archives for the history of creating

[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: > There is no such constrain. Why not? Any example where it does make sense to have different types for numerator and denominator? -- ___ Python tracker

[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There is no such constrain. And no default implementation in this module depends on the constructor. It is important, the constructor is not the part of interfaces. If you want to return the same type in denominator, just override it in your class.

[issue47079] Integral.denominator shouldn't return an int

2022-03-26 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: > How would it work for bool or IntEnum? Neither subclass the Integral abc. The constraint (for which I care about) is: numerator/denominator should have same types. The default implementation, which I propose: it's the same type as the given Integral

[issue47079] Integral.denominator shouldn't return an int

2022-03-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: How would it work for bool or IntEnum? -- nosy: +lemburg, mark.dickinson, stutzbach ___ Python tracker ___

[issue47079] Integral.denominator shouldn't return an int

2022-03-25 Thread Terry J. Reedy
Terry J. Reedy added the comment: Raymond and Serhiy, you were the last two active devs to touch numbers.py. -- nosy: +rhettinger, serhiy.storchaka, terry.reedy ___ Python tracker

[issue47079] Integral.denominator shouldn't return an int

2022-03-21 Thread Sergey B Kirpichev
Change by Sergey B Kirpichev : -- keywords: +patch pull_requests: +30110 stage: -> patch review pull_request: https://github.com/python/cpython/pull/32022 ___ Python tracker

[issue47079] Integral.denominator shouldn't return an int

2022-03-20 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: > self(1) instead or, rather, type(self)(1) -- ___ Python tracker ___ ___ Python-bugs-list

[issue47079] Integral.denominator shouldn't return an int

2022-03-20 Thread Sergey B Kirpichev
New submission from Sergey B Kirpichev : As the __int__() method is required, I believe it can return self(1) instead. Also, probably +self normalization could be avoided in the Integral.numerator(). -- components: Library (Lib) messages: 415660 nosy: Sergey.Kirpichev priority: normal