internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: python-telegram-bot/python-telegram-bot

Issue:
[FEATURE] Make vendored urllib3 optional during setup.py
This is following the request in #1568 

We need to be able to identify when this is the case, thus `python -m telegram` should provide adequate information.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -3,6 +3,8 @@
 
 import codecs
 import os
+import sys
+
 from setuptools import setup, find_packages
 
 
@@ -18,6 +20,14 @@ def requirements():
 
 
 packages = find_packages(exclude=['tests*'])
+requirements = requirements()
+
+# Allow for a package install to not use the vendored urllib3
+UPSTREAM_URLLIB3_FLAG = '--with-upstream-urllib3'
+if UPSTREAM_URLLIB3_FLAG in sys.argv:
+    sys.argv.remove(UPSTREAM_URLLIB3_FLAG)
+    requirements.append('urllib3 >= 1.19.1')
+    packages = [x for x in packages if not x.startswith('telegram.vendor.ptb_urllib3')]
 
 with codecs.open('README.rst', 'r', 'utf-8') as fd:
     fn = os.path.join('telegram', 'version.py')
@@ -35,7 +45,7 @@ def requirements():
           description="We have made you a wrapper you can't refuse",
           long_description=fd.read(),
           packages=packages,
-          install_requires=requirements(),
+          install_requires=requirements,
           extras_require={
               'json': 'ujson',
               'socks': 'PySocks'
diff --git a/telegram/utils/request.py b/telegram/utils/request.py
--- a/telegram/utils/request.py
+++ b/telegram/utils/request.py
@@ -38,9 +38,20 @@
     from telegram.vendor.ptb_urllib3.urllib3.util.timeout import Timeout
     from telegram.vendor.ptb_urllib3.urllib3.fields import RequestField
 except ImportError:  # pragma: no cover
-    warnings.warn("python-telegram-bot wasn't properly installed. Please refer to README.rst on "
-                  "how to properly install.")
-    raise
+    try:
+        import urllib3
+        import urllib3.contrib.appengine as appengine
+        from urllib3.connection import HTTPConnection
+        from urllib3.util.timeout import Timeout
+        from urllib3.fields import RequestField
+        warnings.warn('python-telegram-bot is using upstream urllib3. This is allowed but not '
+                      'supported by python-telegram-bot maintainers.')
+    except ImportError:
+        warnings.warn(
+            "python-telegram-bot wasn't properly installed. Please refer to README.rst on "
+            "how to properly install.")
+        raise
+
 
 from telegram import (InputFile, TelegramError, InputMedia)
 from telegram.error import (Unauthorized, NetworkError, TimedOut, BadRequest, ChatMigrated,


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
Python supported versions need to be updated in docs
Not really a bug, but for example it still says Python 3.4 is supported in readme and setup explanations.

Copy-pasting from https://pypi.org/project/python-telegram-bot/ :

> This library provides a pure Python interface for the Telegram Bot API. It’s compatible with Python versions 2.7, 3.3+ and PyPy.



Discussion:
Jup. Please see #1538 and the corresponding PR ;)
@Bibo-Joshi That issue is about python 3.5 and not 2.7. would only need to be dropped in setup, docs and readme.
Mh … Well, you like to update, it doesn't hurt. Just figured that the removal of 2.7 is the important one, which is covered by #1538 
We officially dropped support when python dropped support. We just need to reflect this. Currently, installation fails with 3.5.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -50,10 +50,7 @@ def requirements():
               'Topic :: Communications :: Chat',
               'Topic :: Internet',
               'Programming Language :: Python',
-              'Programming Language :: Python :: 2',
-              'Programming Language :: Python :: 2.7',
               'Programming Language :: Python :: 3',
-              'Programming Language :: Python :: 3.4',
               'Programming Language :: Python :: 3.5',
               'Programming Language :: Python :: 3.6',
               'Programming Language :: Python :: 3.7'


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
[BUG] Duplicates in Filters doc
Both `Filters.document.category` and `Filters.document.mime_type` appear twice in the filters docs


Discussion:

Resolving patch:
diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py
--- a/telegram/ext/filters.py
+++ b/telegram/ext/filters.py
@@ -481,38 +481,6 @@ def filter(self, message):
         ``Filters.document`` for all document messages.
 
     Attributes:
-        category: This Filter filters documents by their category in the mime-type attribute.
-
-            Example:
-                ``Filters.documents.category('audio/')`` filters all types
-                of audio sent as file, for example 'audio/mpeg' or 'audio/x-wav'. The following
-                attributes can be used as a shortcut like: ``Filters.document.audio``
-
-        application:
-        audio:
-        image:
-        video:
-        text:
-        mime_type: This Filter filters documents by their mime-type attribute.
-
-            Example:
-                ``Filters.documents.mime_type('audio/mpeg')`` filters all audio in mp3 format. The
-                following attributes can be used as a shortcut like: ``Filters.document.jpg``
-        apk:
-        doc:
-        docx:
-        exe:
-        gif:
-        jpg:
-        mp3:
-        pdf:
-        py:
-        svg:
-        txt:
-        targz:
-        wav:
-        xml:
-        zip:
         category: This Filter filters documents by their category in the mime-type attribute
 
             Note:


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
[FEATURE] User.send_poll shortcut
We have `Chat.send_poll` as shortcut, but `User` was neglected in #1418


Discussion:

Resolving patch:
diff --git a/telegram/user.py b/telegram/user.py
--- a/telegram/user.py
+++ b/telegram/user.py
@@ -296,3 +296,16 @@ def send_voice(self, *args, **kwargs):
 
         """
         return self.bot.send_voice(self.id, *args, **kwargs)
+
+    def send_poll(self, *args, **kwargs):
+        """Shortcut for::
+
+            bot.send_poll(User.id, *args, **kwargs)
+
+        Where User is the current instance.
+
+        Returns:
+            :class:`telegram.Message`: On success, instance representing the message posted.
+
+        """
+        return self.bot.send_poll(self.id, *args, **kwargs)


Test patch:
diff --git a/tests/test_user.py b/tests/test_user.py
--- a/tests/test_user.py
+++ b/tests/test_user.py
@@ -190,6 +190,13 @@ def test(*args, **kwargs):
         monkeypatch.setattr(user.bot, 'send_animation', test)
         assert user.send_animation('test_animation')
 
+    def test_instance_method_send_poll(self, monkeypatch, user):
+        def test(*args, **kwargs):
+            return args[0] == user.id and args[1] == 'test_poll'
+
+        monkeypatch.setattr(user.bot, 'send_poll', test)
+        assert user.send_poll('test_poll')
+
     def test_mention_html(self, user):
         expected = u'<a href="tg://user?id={}">{}</a>'
Repository: python-telegram-bot/python-telegram-bot

Issue:
Add support for Py 3.9
With Py 3.9 out, we should add it to the tests at some point. Maybe that can wait, until 3.9.x, x>0 is out, though

Need to check, if all the job thingies work out, as APS doesn't support py3.9 yet and there has been a [report](https://t.me/pythontelegrambotgroup/382731) that it doesn't work (with PTB).

On a related note: APS seems to be [preparing for v4.0](https://github.com/agronholm/apscheduler/issues/465), which will break some stuff, but also supports py3.9 and even uses the new ZoneInfo (also backporting to py3.6+), lifting the restriction to use `pytz` timezones. I already subscribed to releases. I guess updating APS in PTB should be done only when 4.x, x>0 is out and we're doing breaking things anyway …


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -64,4 +64,5 @@ def requirements():
               'Programming Language :: Python :: 3.6',
               'Programming Language :: Python :: 3.7',
               'Programming Language :: Python :: 3.8',
+              'Programming Language :: Python :: 3.9',
           ],)


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -15,7 +15,7 @@ jobs:
     runs-on: ${{matrix.os}}
     strategy:
       matrix:
-        python-version: [3.6, 3.7, 3.8]
+        python-version: [3.6, 3.7, 3.8, 3.9]
         os: [ubuntu-latest, windows-latest]
         include:
           - os: ubuntu-latest
@@ -31,7 +31,7 @@ jobs:
         run:
           git submodule update --init --recursive
       - name: Set up Python ${{ matrix.python-version }}
-        uses: actions/setup-python@v1
+        uses: actions/setup-python@v2
         with:
           python-version: ${{ matrix.python-version }}
       - name: Install dependencies
Repository: python-telegram-bot/python-telegram-bot

Issue:
mypy doesn't pick up type hints[BUG]
<!--
Thanks for reporting issues of python-telegram-bot!

Use this template to notify us if you found a bug.

To make it easier for us to help you please enter detailed information below.

Please note, we only support the latest version of python-telegram-bot and
master branch. Please make sure to upgrade & recreate the issue on the latest
version prior to opening an issue.
-->
### Steps to reproduce
1. import python-telegram-bot modules into your `test.py` file (e.g. `from telegram import InlineKeyboardMarkup`)

2. run `mypy test.py`

3. receive the following output `error: Skipping analyzing 'telegram': found module but no type hints or library stubs`

### Expected behaviour
mypy should pickup the typehints as they've been added in the latest release (version `13` )

### Actual behaviour
mypy doesn't pickup the typehints.

I'm confident this can be solved by either

1. adding `python-telegram-bot` to `typeshed` 
2. adding a `py.typed` file

More information can be found [here.](https://stackoverflow.com/questions/60856237/mypy-cant-find-type-hints-for-black)

### Configuration
**Operating System:**
Ubuntu 18.04

**Version of Python, python-telegram-bot & dependencies:**

``$ python -m telegram``
python-telegram-bot 13.0
certifi 2020.06.20
Python 3.8.0 (default, Oct 30 2020, 19:06:04)  [GCC 7.5.0]
### Logs
```
error: Skipping analyzing 'telegram.ext': found module but no type hints or library stubs
note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
error: Skipping analyzing 'telegram': found module but no type hints or library stubs
error: Skipping analyzing 'telegram.ext': found module but no type hints or library stubs
error: Skipping analyzing 'telegram': found module but no type hints or library stubs
```


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -45,6 +45,7 @@ def requirements():
           description="We have made you a wrapper you can't refuse",
           long_description=fd.read(),
           packages=packages,
+          package_data={'telegram': ['py.typed']},
           install_requires=requirements,
           extras_require={
               'json': 'ujson',


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
[FEATURE] Add convenience property `id` to `Message`
## Current situation

Telegram currently offers attribute `message_id` to `Message`. But this is inconsistent with the rest of their API, e.g. `Chat.id`, `User.id`, `InlineQuery.id`, etc. We can offer a convenience property `Message.id` which will make it more consistent and make it less prone to errors, e.g. when someone forgets it's `message_id` and not `id`. 

## Proposed change

Add the property `id` to `Message` which just returns `self.message_id`. A similar example can be found [here](https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/_message.py#L570-L573).

## A PR for this issue should

- Add a docstring along with a `.. versionadded:: 20.0` directive to the function.
- Add an unit test to `test_message.py` that ensures that this works as expected and is the same as `Message.message_id`.

## Additional Info

We have a [contribution guide](https://python-telegram-bot.readthedocs.io/en/v20.0a0/contributing.html)


Discussion:
@harshil21 can i take this?
Sure, assigning you.
@harshil21 apparently 'id' is not a valid name. It gets blocked by the pre-commit scripts although it passes the unit test

Resolving patch:
diff --git a/telegram/_message.py b/telegram/_message.py
--- a/telegram/_message.py
+++ b/telegram/_message.py
@@ -572,6 +572,15 @@ def chat_id(self) -> int:
         """:obj:`int`: Shortcut for :attr:`telegram.Chat.id` for :attr:`chat`."""
         return self.chat.id
 
+    @property
+    def id(self) -> int:  # pylint: disable=invalid-name
+        """
+        :obj:`int`: Shortcut for :attr:`message_id`.
+
+            .. versionadded:: 20.0
+        """
+        return self.message_id
+
     @property
     def link(self) -> Optional[str]:
         """:obj:`str`: Convenience property. If the chat of the message is not


Test patch:
diff --git a/tests/test_message.py b/tests/test_message.py
--- a/tests/test_message.py
+++ b/tests/test_message.py
@@ -664,6 +664,9 @@ async def test_parse_entities_url_emoji(self):
     def test_chat_id(self, message):
         assert message.chat_id == message.chat.id
 
+    def test_id(self, message):
+        assert message.message_id == message.id
+
     @pytest.mark.parametrize("type_", argvalues=[Chat.SUPERGROUP, Chat.CHANNEL])
     def test_link_with_username(self, message, type_):
         message.chat.username = "username"
Repository: python-telegram-bot/python-telegram-bot

Issue:
[BUG] Missing log-decorator(s)
### Steps to Reproduce

`Bot.get_webhook_info` is missing the `@_log` decorator

### Expected behaviour

It should have the decorator

### Actual behaviour

It's not having it

### Operating System

-

### Version of Python, python-telegram-bot & dependencies

```shell
master
```


### Relevant log output

_No response_

### Additional Context

We should also add a unit tests that checks that all bot methods have the decorator.


Discussion:

Resolving patch:
diff --git a/telegram/_bot.py b/telegram/_bot.py
--- a/telegram/_bot.py
+++ b/telegram/_bot.py
@@ -3929,6 +3929,7 @@ async def delete_chat_sticker_set(
         )
         return result
 
+    @_log
     async def get_webhook_info(
         self,
         *,


Test patch:
diff --git a/tests/test_bot.py b/tests/test_bot.py
--- a/tests/test_bot.py
+++ b/tests/test_bot.py
@@ -22,6 +22,7 @@
 import inspect
 import logging
 import pickle
+import re
 import socket
 import sys
 import time
@@ -320,6 +321,18 @@ async def test_log_decorator(self, bot, caplog):
             assert caplog.records[0].getMessage().startswith("Entering: get_me")
             assert caplog.records[-1].getMessage().startswith("Exiting: get_me")
 
+    @bot_methods(ext_bot=False)
+    def test_api_methods_have_log_decorator(self, bot_class, bot_method_name, bot_method):
+        """Check that all bot methods have the log decorator ..."""
+        # not islower() skips the camelcase aliases
+        if not bot_method_name.islower():
+            return
+        source = inspect.getsource(bot_method)
+        assert (
+            # Use re.match to only match at *the beginning* of the string
+            re.match(rf"\s*\@\_log\s*async def {bot_method_name}", source)
+        ), f"{bot_method_name} is missing the @_log decorator"
+
     @pytest.mark.parametrize(
         "acd_in,maxsize",
         [(True, 1024), (False, 1024), (0, 0), (None, None)],
Repository: python-telegram-bot/python-telegram-bot

Issue:
[FEATURE] convenience property for displaying name of Chat object
### What kind of feature are you missing? Where do you notice a shortcoming of PTB?

Because `Chat` objects can be private or groups/user/channels, one needs to check the type every time before using the appropriate property (`Chat.full_name` or `Chat.title` respectively). It would be nice to have a conveniente property that does this automatically

### Describe the solution you'd like

I propose a convenience property that return `Chat.full_name` if the chat.type is private or `Chat.title` otherwise.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_


Discussion:
I'll make a PR this afternoon
> I'll make a PR this afternoon

sure, assigning to you :+1: 

Resolving patch:
diff --git a/telegram/_chat.py b/telegram/_chat.py
--- a/telegram/_chat.py
+++ b/telegram/_chat.py
@@ -388,10 +388,24 @@ def __init__(
 
         self._freeze()
 
+    @property
+    def effective_name(self) -> Optional[str]:
+        """
+        :obj:`str`: Convenience property. Gives :attr:`title` if not :obj:`None`,
+        else :attr:`full_name` if not :obj:`None`.
+
+        .. versionadded:: 20.1
+        """
+        if self.title is not None:
+            return self.title
+        if self.full_name is not None:
+            return self.full_name
+        return None
+
     @property
     def full_name(self) -> Optional[str]:
         """
-        :obj:`str`: Convenience property. If :attr:`first_name` is not :obj:`None` gives,
+        :obj:`str`: Convenience property. If :attr:`first_name` is not :obj:`None`, gives
         :attr:`first_name` followed by (if available) :attr:`last_name`.
 
         Note:


Test patch:
diff --git a/tests/test_chat.py b/tests/test_chat.py
--- a/tests/test_chat.py
+++ b/tests/test_chat.py
@@ -212,6 +212,16 @@ def test_full_name(self):
         )
         assert chat.full_name is None
 
+    def test_effective_name(self):
+        chat = Chat(id=1, type=Chat.PRIVATE, first_name="first\u2022name")
+        assert chat.effective_name == "first\u2022name"
+        chat = Chat(id=1, type=Chat.GROUP, title="group")
+        assert chat.effective_name == "group"
+        chat = Chat(id=1, type=Chat.GROUP, first_name="first\u2022name", title="group")
+        assert chat.effective_name == "group"
+        chat = Chat(id=1, type=Chat.GROUP)
+        assert chat.effective_name is None
+
     async def test_send_action(self, monkeypatch, chat):
         async def make_assertion(*_, **kwargs):
             id_ = kwargs["chat_id"] == chat.id
Repository: python-telegram-bot/python-telegram-bot

Issue:
Stability policy/api update guidelines
I felt like an issue is the proper place to discuss this, since we are going to make some decisions on how to handle API updates from now on which are bigger then simple doc behavior.

Hinrich suggested the following list of points to be included in the contributing guide, where we need to standardize our approach:

* deprecated optional arguments
* deprecated positional arguments
* new positional arguments that change the order
* deprecated attributes
* equality comparison
* issuing deprecation warnings
* handling api_kwargs
* clarifying how long deprecated functionality will still be available
* `to_dict`
* maybe more

> deprecated optional/positional arguments/attributes

I would warn a DeprecationWarning, and remove the old ones in the next major version.

> new positional arguments that change the order

I think here its enough to mention in the version string, people should name their arguments or expect to have issues.

> equality comparison

I would add the new stuff, an object without it is different then one with

That's is all I feel comfortable commenting about right now.


Discussion:

Resolving patch:
diff --git a/telegram/_telegramobject.py b/telegram/_telegramobject.py
--- a/telegram/_telegramobject.py
+++ b/telegram/_telegramobject.py
@@ -58,6 +58,12 @@ class TelegramObject:
     The :mod:`pickle` and :func:`~copy.deepcopy` behavior of objects of this type are defined by
     :meth:`__getstate__`, :meth:`__setstate__` and :meth:`__deepcopy__`.
 
+    Tip:
+        Objects of this type can be serialized via Python's :mod:`pickle` module and pickled
+        objects from one version of PTB are usually loadable in future versions. However, we can
+        not guarantee that this compatibility will always be provided. At least a manual one-time
+        conversion of the data may be needed on major updates of the library.
+
     .. versionchanged:: 20.0
 
         * Removed argument and attribute ``bot`` for several subclasses. Use
diff --git a/telegram/error.py b/telegram/error.py
--- a/telegram/error.py
+++ b/telegram/error.py
@@ -55,6 +55,12 @@ class TelegramError(Exception):
     """
     Base class for Telegram errors.
 
+    Tip:
+        Objects of this type can be serialized via Python's :mod:`pickle` module and pickled
+        objects from one version of PTB are usually loadable in future versions. However, we can
+        not guarantee that this compatibility will always be provided. At least a manual one-time
+        conversion of the data may be needed on major updates of the library.
+
     .. seealso:: :wiki:`Exceptions, Warnings and Logging <Exceptions%2C-Warnings-and-Logging>`
     """
 


Test patch:
Repository: python-telegram-bot/python-telegram-bot

Issue:
Add rich equality comparison to `WriteAccessAllowed`
The comparison should be based on the `web_app_name` attribute only.

See https://github.com/python-telegram-bot/python-telegram-bot/pull/3898#discussion_r1337582872


Discussion:

Resolving patch:
diff --git a/telegram/_writeaccessallowed.py b/telegram/_writeaccessallowed.py
--- a/telegram/_writeaccessallowed.py
+++ b/telegram/_writeaccessallowed.py
@@ -28,7 +28,12 @@ class WriteAccessAllowed(TelegramObject):
     This object represents a service message about a user allowing a bot to write messages after
     adding the bot to the attachment menu or launching a Web App from a link.
 
+    Objects of this class are comparable in terms of equality. Two objects of this class are
+    considered equal, if their :attr:`web_app_name` is equal.
+
     .. versionadded:: 20.0
+    .. versionchanged:: NEXT.VERSION
+       Added custom equality comparison for objects of this class.
 
     Args:
         web_app_name (:obj:`str`, optional): Name of the Web App which was launched from a link.
@@ -50,4 +55,6 @@ def __init__(
         super().__init__(api_kwargs=api_kwargs)
         self.web_app_name: Optional[str] = web_app_name
 
+        self._id_attrs = (self.web_app_name,)
+
         self._freeze()


Test patch:
diff --git a/tests/test_writeaccessallowed.py b/tests/test_writeaccessallowed.py
--- a/tests/test_writeaccessallowed.py
+++ b/tests/test_writeaccessallowed.py
@@ -36,3 +36,22 @@ def test_to_dict(self):
         action = WriteAccessAllowed()
         action_dict = action.to_dict()
         assert action_dict == {}
+
+    def test_equality(self):
+        a = WriteAccessAllowed()
+        b = WriteAccessAllowed()
+        c = WriteAccessAllowed(web_app_name="foo")
+        d = WriteAccessAllowed(web_app_name="foo")
+        e = WriteAccessAllowed(web_app_name="bar")
+
+        assert a == b
+        assert hash(a) == hash(b)
+
+        assert a != c
+        assert hash(a) != hash(c)
+
+        assert c == d
+        assert hash(c) == hash(d)
+
+        assert c != e
+        assert hash(c) != hash(e)