-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add __repr__ methods for selected classes
#3826
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
Conversation
|
I actually highly prefer having magic methods in the beginning of a class, since they define the behaviour of a class. Don't know why none of the linters support such a thing. Let's make a new issue to do this if everyone thinks the same. |
I also like having all magic methods in one place. Since
I don't see really the benefit of that …
shouldn't that be available as |
for some reason I decided to include the size of the queue. I think it could be helpful for the user.
Numbers of states could be useful because a user that has multiple `ConversationHandler`s might easily recognize the handler by these numbers even if it has no name.
|
I should create some tests for these methods, right? |
Bibo-Joshi
left a comment
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 should create some tests for these methods, right?
Yes please! :) Even if we don't document this behavior I'd like to avoid regressions.
I only just now looked at the changes for the first time and I see that your style of __repr__ indeed reads like a short description. It definetily has benefits in terms of being easier to understand 👍 The downside is that it's easier to get a bit lengthy so that I would suggest to double check the wording & printed information in terms of length. I also now better understand your question about <…> :D That does in fact make more sense to me now as with this style it is more important to have some markers for the start and end of the representation. You could write a small helper for f"<{stuff}>" to make it easy to apply the same style everywhere.
TBH I always had something like Application(bot=…) in mind, but I do see that this assumption is in no way the only (or even "best") thing to do. The upside is that it's shorter, the downside is that's a bit less easy to understand. A downside is that it suggests that you can instantiate the object like that which is not always the case. Using e.g. square brackets instead could alleviate the problem a bit, but I admit that I like the general descriptive style a bit better for these "highlevel" classes (note that for the TG classes which are mostly "data classes", the ClassName(…) repr still makes sense for me).
I don' think we ever planned to create |
Sure we did: |
OK, I was being inattentive and imprecise (need a third flaw to make a combo). But the point of my message was, "we're not doing anything to TO here in this PR" :) In your comment you were obviously referring to the existing practice, and I misunderstood it. |
How about we write something like |
I'm not sure if that's much better. Thinking about it, e.g. for Jobs the trigger is actually not an argument that we directly pass to neither |
harshil21
left a comment
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.
good feature to have!
Poolitzer
left a comment
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 like it
|
I was about to hit merge - but then I remembered one more thing 🙈 For |
consistency is key! :) |
harshil21
left a comment
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.
lgtm again :)
Poolitzer
left a comment
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.
LGTM
|
DS failure unrelated - see #3888. Merging. PS: Will open a follow-up issue on #3826 (comment) PPS: I'm blind - that was already addressed |
closes #3770