Skip to content

Update _message.py - issue #2606 #2741

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

Closed
wants to merge 43 commits into from
Closed

Conversation

nivramam
Copy link

@nivramam nivramam commented Oct 21, 2021

closes #2606

Checklist for PR

  • modified message.photo = None instead of an empty list []
  • Added .. versionadded:: version, .. versionchanged:: version or .. deprecated:: version to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
  • Created new or adapted existing unit tests
  • Added myself alphabetically to AUTHORS.rst (optional)

Bibo-Joshi and others added 30 commits October 3, 2021 20:12
…t#2612)

Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Signed-off-by: starry69 <starry369126@outlook.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
…m-bot#2634)

Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
@nivramam
Copy link
Author

Well, yes, making these changes everywhere where necessary is what we want. In addition

Please also make sure to add versioning directives and we should also add some tests for the changed attributes to make sure that they're None and not []

Sure, will do. Due to my exams I wasn't online here for 2 days. Will do so and give an update. Thx!

@nivramam
Copy link
Author

nivramam commented Oct 29, 2021

Hi, so I fetched the latest from branch v14 yesterday. Later yesterday I noticed 1 check being canceled, which I am not aware of. And mainly I haven't changed/modified anything for it to fail. I just fetched upstream all the changes that were implemented in the past week. Have been trying to learn where the check has been canceled.

Surfed the same issue on the internet and people tend to say it's sometimes failing for some reason and not due to our PR. Anyway, I just thought of asking you guys. thanks in advance :)

Note: Attaching the screenshot of what is displayed for me in this page
Edit: Along with that, it also says there's no conflicts

image

@Poolitzer
Copy link
Member

Don't worry about the checks until you implemented all the changes and then the feedback of the maintainers :D

@nivramam
Copy link
Author

Okay, thanks!

@harshil21 harshil21 added this to the v14 milestone Nov 4, 2021
@nivramam
Copy link
Author

Hi, having a qq, while I was resolving a similar [] empty list issue in replykeyboardmarkup. Have described the same over here #2606 (comment)

test_message: test for updated change reg issue python-telegram-bot#2606

reply_keyboard_markup : ensure self.keyboard is not null before assigning to attributes
@nivramam
Copy link
Author

Hi so I have added tests for the already implemented changes (test_message.py). Apart from that, the above mentioned addition of a null check on keyboardmarkup too I have committed to review the checks. Thx! And also I am in the process of reviewing other similar changes. Will update here as and when I complete them.

Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Sorry for the late reply. I addressed your question on ReplyKeyboardMarkup below.
I'll do a more thorough review once you indicate that you've made all required changes :)

@@ -468,7 +468,7 @@ def __init__(
self.audio = audio
self.game = game
self.document = document
self.photo = photo or []
self.photo = photo or None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the or None is redundant :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right yes, shall modify it :)

Comment on lines +117 to +119
# ensure keyboard is notnull before assigning
if self.keyboard:
self._id_attrs = (self.keyboard,)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check is necessary. keyboard is a mandatory argument and if the user passes something that's not a list of lists of buttons, that's their fault.
Additionally, the sanity check in line 95 alread checks the "list of lists" part. So if we get here, self.keyboard is [[]] in the worst case, which will pass the if self.keyboard check.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Yeah the check at 95 was there, but I thought for ensuring the null check would be necessary.

But thanks to your comment, I just reviewed and realized it doesn't get to null anywhere. Sure will do changes and let you know

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And regarding conflicts there is a huge number of conflicts showing up now but wasn't there when I pushed yesterday.. Is it for me alone?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just pull from v14 into this branch, it should be fine :)

Copy link
Author

@nivramam nivramam Dec 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have tried to do it. I was prompted to create a PR and I did so, but now I am stuck here. Could you pls give me a solution so that I have the latest V14? Thanks in advance!

P.S: Due to my access issue I was unable to login to Github and hence the delay.

Here's the screen of the PR that I created when prompted.
image

Also in the current PR thread, I am notified that there are conflicts that cannot be automatically resolved..

@Bibo-Joshi
Copy link
Member

Hi. We discussed this issue in the dev chat again and had a bit of a change of heart. While the main argument to change to None was to be uniform with the other attributes, the benfits of [] are compelling and the issue of uniformness can be largely circumvented by properly adapting the documentation. E.g. the docstring for Message.photo currently reads

photo (List[:class:telegram.PhotoSize]): Optional. Available sizes of the photo.

and should be changed to something like

photo (List[:class:telegram.PhotoSize]): Available sizes of the photo. This list is empty if the message doesn't contain a photo.

@nivramam I'm sorry that we reverted our decision only after you started to work on this PR. I hope that you haven't put too much time into it and that you can understand our decision. If your are interested, you're very welcome to instead PR for the mentioned updates of the documentation. In this case, please fetch the current doc-fixes branch and create a new branch based on that to add your changes to.

@nivramam
Copy link
Author

Hi. We discussed this issue in the dev chat again and had a bit of a change of heart. While the main argument to change to None was to be uniform with the other attributes, the benfits of [] are compelling and the issue of uniformness can be largely circumvented by properly adapting the documentation. E.g. the docstring for Message.photo currently reads

photo (List[:class:telegram.PhotoSize]): Optional. Available sizes of the photo.

and should be changed to something like

photo (List[:class:telegram.PhotoSize]): Available sizes of the photo. This list is empty if the message doesn't contain a photo.

@nivramam I'm sorry that we reverted our decision only after you started to work on this PR. I hope that you haven't put too much time into it and that you can understand our decision. If your are interested, you're very welcome to instead PR for the mentioned updates of the documentation. In this case, please fetch the current doc-fixes branch and create a new branch based on that to add your changes to.

Oh fine. Yes no issues on my side since I didn't have access to GitHub in the last month so no more updates from my side.

Sure will try to PR the mentioned updates. Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Jan 5, 2022
@Bibo-Joshi Bibo-Joshi added 🔌 bug pr description: bug and removed bug 🐛 labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔌 bug pr description: bug 📋 pending-reply work status: pending-reply
Projects
None yet
Development

Successfully merging this pull request may close these issues.