-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[9481] Change DelayedCall repr to include details #1068
Conversation
Codecov Report
@@ Coverage Diff @@
## trunk #1068 +/- ##
==========================================
+ Coverage 91.92% 91.92% +<.01%
==========================================
Files 844 844
Lines 150879 150868 -11
Branches 13158 13158
==========================================
- Hits 138694 138685 -9
+ Misses 10099 10097 -2
Partials 2086 2086 |
e55a564
to
fcdf3ac
Compare
I moved the epytext syntax fix to #1069 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
object.__str__()
already falls back on __repr__()
so I would think it would be tidier to rename the method to __repr__()
than to assign the method to both attribute names?
https://docs.python.org/3/reference/datamodel.html#object.__str__
@altendky I thought about doing it that way, but then the behavior would be different if |
@twm, in what scenario are you saying there would be a difference? https://repl.it/@altendky/twisted-t9481-pr1068-001 exampleclass ReprEqStr:
def __str__(self):
return "base"
__repr__ = __str__
class ReprEqStrChild(ReprEqStr):
def __str__(self):
return "inherited"
print(str(ReprEqStr()))
print(repr(ReprEqStr()))
print(str(ReprEqStrChild()))
print(repr(ReprEqStrChild()))
print()
class Repr:
def __repr__(self):
return "base"
class ReprChild(Repr):
def __str__(self):
return "inherited"
print(str(Repr()))
print(repr(Repr()))
print(str(ReprChild()))
print(repr(ReprChild()))
|
Good point... I didn't think that through. If it were implemented like this: class DelayedCall:
def __str__(self):
return '...'
def __repr__(self):
return self.__str__() Then it would be different. I'm torn... does being this fastidious about subclassability even matter here? Thank you for your attention to detail! |
I guess I'm not understanding why we want this functionality ( twisted/src/twisted/python/usage.py Line 198 in 5492c16
|
The existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do generally look forward to better code but I know practically it's appropriate to maintain backwards compatibility. I just don't think this extends to implementation details of _
-starting things. But, I won't be offended if you want someone with a bit more experience with Twisted policies to weigh in. :]
Please merge.
(https://twistedmatrix.com is down at the moment, appropriate comment in ticket pending availability) |
Thank you for the review @altendky! I will merge when the merge forward goes green. |
This turns out to be quite simple, as there is already a
__str__
implementation that does the necessary: we can just alias__repr__
to__str__
.Contributor Checklist: