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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5948095
Temporarily enable tests for the v14 branch
Bibo-Joshi Jul 14, 2021
53aca25
Move and Rename TelegramDecryptionError to telegram.error.PassportDec…
harshil21 Aug 11, 2021
af2516b
Add Code Comment Guidelines to Contribution Guide (#2612)
Poolitzer Aug 11, 2021
b5723f0
Improve Type Hinting for CallbackContext (#2587)
revolter Aug 12, 2021
6ca92ec
Add Custom pytest Marker to Ease Development (#2628)
Poolitzer Aug 12, 2021
efea686
Make BasePersistence Methods Abstract (#2624)
starry-shivam Aug 12, 2021
104eb17
Refactor Initialization of Persistence Classes (#2604)
Bibo-Joshi Aug 13, 2021
ab262ae
Remove `__dict__` from `__slots__` and drop Python 3.6 (#2619, #2636)
harshil21 Aug 19, 2021
8b7cbcc
Remove day_is_strict argument of JobQueue.run_monthly (#2634)
iota-008 Aug 26, 2021
5630f98
Drop Non-CallbackContext API (#2617)
Poolitzer Aug 29, 2021
09043a4
Fix Signatures and Improve test_official (#2643)
harshil21 Aug 29, 2021
d7a286c
Remove Deprecated Functionality (#2644)
Bibo-Joshi Aug 30, 2021
d652a86
Add User Friendly Type Check For Init Of {Inline, Reply}KeyboardMarku…
harshil21 Sep 15, 2021
bd1e28c
Refine Dispatcher.dispatch_error (#2660)
Bibo-Joshi Sep 17, 2021
a6673c8
Warnings Overhaul (#2662)
harshil21 Sep 20, 2021
b1017ef
Clear Up Import Policy (#2671)
Bibo-Joshi Sep 22, 2021
bf62537
Make InlineQuery.answer Raise ValueError (#2675)
Bibo-Joshi Sep 24, 2021
2b4ab57
Doc Fixes (#2597)
Bibo-Joshi Oct 1, 2021
b630e1b
Move Defaults to telegram.ext (#2648)
Bibo-Joshi Oct 3, 2021
b0385c1
Update Notification Workflows (#2695)
Poolitzer Oct 3, 2021
681393f
Pass Failing Jobs to Error Handlers (#2692)
Bibo-Joshi Oct 3, 2021
2c44dc0
Improve Signature Inspection for Bot Methods (#2686)
harshil21 Oct 3, 2021
6965ae9
Handle Filepaths via the Pathlib Module (#2688)
eldbud Oct 5, 2021
13433e3
Add Filters.update.edited (#2705)
PhilippFr Oct 7, 2021
01be85f
Use Error Messages for Pylint Instead of Codes (#2700)
Piraty Oct 8, 2021
7ba5b3a
Introduce Builder Pattern for Updater and Dispatcher (#2646)
Bibo-Joshi Oct 9, 2021
eec90a0
Mark Internal Modules As Private (#2687)
Oct 10, 2021
163d598
Accept File Paths for Updater/DispatcherBuilder.private_key (#2724)
Bibo-Joshi Oct 11, 2021
1adc96c
Make Tests Agnostic of the CWD (#2727)
eldbud Oct 13, 2021
38a6a6d
Refactor MRO of InputMedia* and Some File-Like Classes (#2717)
eldbud Oct 15, 2021
b24d7d8
Introduce Enums for telegram.constants (#2708)
Bibo-Joshi Oct 19, 2021
14fe06b
Update _message.py
nivramam Oct 21, 2021
5352a05
Introduce TelegramObject.set/get_bot (#2712)
zpavloudis Oct 21, 2021
8f4105d
Remove Job.job_queue (#2740)
Bibo-Joshi Oct 21, 2021
8e3ab4a
Merge branch 'python-telegram-bot:v14' into v14
nivramam Oct 21, 2021
49d8c62
Drop `__dict__` from `Dispatcher.__slots__` (#2745)
Bibo-Joshi Oct 24, 2021
36d09df
Update Exceptions for Immutable Attributes (#2749)
harshil21 Oct 26, 2021
7eecaca
Merge branch 'python-telegram-bot:v14' into v14
nivramam Oct 28, 2021
c81a087
Update Code Quality Dependencies (#2748)
harshil21 Oct 30, 2021
3e8d1fa
Refactor Warnings in ConversationHandler (#2755)
Poolitzer Nov 6, 2021
bdf0dcb
Merge branch 'python-telegram-bot:v14' into v14
nivramam Nov 8, 2021
84636cf
Issue #2606 - update tests
nivramam Nov 18, 2021
6a774bf
Update test_message.py
nivramam Nov 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
74 changes: 51 additions & 23 deletions .github/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,9 @@ Here's how to make a one-off code change.

- Your code should adhere to the `PEP 8 Style Guide`_, with the exception that we have a maximum line length of 99.

- Provide static typing with signature annotations. The documentation of `MyPy`_ will be a good start, the cheat sheet is `here`_. We also have some custom type aliases in ``telegram.utils.helpers.typing``.
- Provide static typing with signature annotations. The documentation of `MyPy`_ will be a good start, the cheat sheet is `here`_. We also have some custom type aliases in ``telegram._utils.types``.

- Document your code. This project uses `sphinx`_ to generate static HTML docs. To build them, first make sure you have the required dependencies:

.. code-block:: bash

$ pip install -r docs/requirements-docs.txt

then run the following from the PTB root directory:

.. code-block:: bash

$ make -C docs html

or, if you don't have ``make`` available (e.g. on Windows):

.. code-block:: bash

$ sphinx-build docs/source docs/build/html

Once the process terminates, you can view the built documentation by opening ``docs/build/html/index.html`` with a browser.

- Add ``.. versionadded:: version``, ``.. versionchanged:: version`` or ``.. deprecated:: version`` to the associated documentation of your changes, depending on what kind of change you made. This only applies if the change you made is visible to an end user. The directives should be added to class/method descriptions if their general behaviour changed and to the description of all arguments & attributes that changed.
- Document your code. This step is pretty important to us, so it has its own `section`_.

- For consistency, please conform to `Google Python Style Guide`_ and `Google Python Style Docstrings`_.

Expand All @@ -105,6 +85,8 @@ Here's how to make a one-off code change.

- Please ensure that the code you write is well-tested.

- In addition to that, we provide the `dev` marker for pytest. If you write one or multiple tests and want to run only those, you can decorate them via `@pytest.mark.dev` and then run it with minimal overhead with `pytest ./path/to/test_file.py -m dev`.

- Don’t break backward compatibility.

- Add yourself to the AUTHORS.rst_ file in an alphabetical fashion.
Expand Down Expand Up @@ -151,7 +133,7 @@ Here's how to make a one-off code change.

5. **Address review comments until all reviewers give LGTM ('looks good to me').**

- When your reviewer has reviewed the code, you'll get an email. You'll need to respond in two ways:
- When your reviewer has reviewed the code, you'll get a notification. You'll need to respond in two ways:

- Make a new commit addressing the comments you agree with, and push it to the same branch. Ideally, the commit message would explain what the commit does (e.g. "Fix lint error"), but if there are lots of disparate review comments, it's fine to refer to the original commit message and add something like "(address review comments)".

Expand Down Expand Up @@ -186,6 +168,49 @@ Here's how to make a one-off code change.

7. **Celebrate.** Congratulations, you have contributed to ``python-telegram-bot``!

Documenting
===========

The documentation of this project is separated in two sections: User facing and dev facing.

User facing docs are hosted at `RTD`_. They are the main way the users of our library are supposed to get information about the objects. They don't care about the internals, they just want to know
what they have to pass to make it work, what it actually does. You can/should provide examples for non obvious cases (like the Filter module), and notes/warnings.

Dev facing, on the other side, is for the devs/maintainers of this project. These
doc strings don't have a separate documentation site they generate, instead, they document the actual code.

User facing documentation
-------------------------
We use `sphinx`_ to generate static HTML docs. To build them, first make sure you have the required dependencies:

.. code-block:: bash

$ pip install -r docs/requirements-docs.txt

then run the following from the PTB root directory:

.. code-block:: bash

$ make -C docs html

or, if you don't have ``make`` available (e.g. on Windows):

.. code-block:: bash

$ sphinx-build docs/source docs/build/html

Once the process terminates, you can view the built documentation by opening ``docs/build/html/index.html`` with a browser.

- Add ``.. versionadded:: version``, ``.. versionchanged:: version`` or ``.. deprecated:: version`` to the associated documentation of your changes, depending on what kind of change you made. This only applies if the change you made is visible to an end user. The directives should be added to class/method descriptions if their general behaviour changed and to the description of all arguments & attributes that changed.

Dev facing documentation
------------------------
We adhere to the `CSI`_ standard. This documentation is not fully implemented in the project, yet, but new code changes should comply with the `CSI` standard.
The idea behind this is to make it very easy for you/a random maintainer or even a totally foreign person to drop anywhere into the code and more or less immediately understand what a particular line does. This will make it easier
for new to make relevant changes if said lines don't do what they are supposed to.



Style commandments
------------------

Expand Down Expand Up @@ -252,4 +277,7 @@ break the API classes. For example:
.. _`here`: https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html
.. _`Black`: https://black.readthedocs.io/en/stable/index.html
.. _`popular editors`: https://black.readthedocs.io/en/stable/editor_integration.html
.. _`RTD`: https://python-telegram-bot.readthedocs.io/
.. _`RTD build`: https://python-telegram-bot.readthedocs.io/en/doc-fixes
.. _`CSI`: https://standards.mousepawmedia.com/en/stable/csi.html
.. _`section`: #documenting
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Hey! You're PRing? Cool! Please have a look at the below checklist. It's here to

- [ ] 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
- [ ] Documented code changes according to the [CSI standard](https://standards.mousepawmedia.com/en/stable/csi.html)
- [ ] Added myself alphabetically to `AUTHORS.rst` (optional)


Expand All @@ -24,7 +25,10 @@ Hey! You're PRing? Cool! Please have a look at the below checklist. It's here to
* If relevant:

- [ ] Added new constants at `telegram.constants` and shortcuts to them as class variables
- [ ] Link new and existing constants in docstrings instead of hard coded number and strings
- [ ] Add new message types to `Message.effective_attachment`
- [ ] Added new handlers for new update types
- [ ] Add the handlers to the warning loop in the `ConversationHandler`
- [ ] Added new filters for new message (sub)types
- [ ] Added or updated documentation for the changed class(es) and/or method(s)
- [ ] Updated the Bot API version number in all places: `README.rst` and `README_RAW.rst` (including the badge), as well as `telegram.constants.BOT_API_VERSION`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example_notifier.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Warning maintainers
on:
pull_request:
pull_request_target:
paths: examples/**
jobs:
job:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit_dependencies_notifier.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Warning maintainers
on:
pull_request:
pull_request_target:
paths:
- requirements.txt
- requirements-dev.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/readme_notifier.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Warning maintainers
on:
pull_request:
pull_request_target:
paths:
- README.rst
- README_RAW.rst
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ on:
pull_request:
branches:
- master
- v14
push:
branches:
- master
- v14

jobs:
pytest:
name: pytest
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: False
steps:
Expand All @@ -34,7 +36,7 @@ jobs:

- name: Test with pytest
# We run 3 different suites here
# 1. Test just utils.helpers.py without pytz being installed
# 1. Test just utils.datetime.py without pytz being installed
# 2. Test just test_no_passport.py without passport dependencies being installed
# 3. Test everything else
# The first & second one are achieved by mocking the corresponding import
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ target/
# Sublime Text 2
*.sublime*

# VS Code
.vscode

# unitests files
game.gif
telegram.mp3
Expand Down
17 changes: 11 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
# * the additional_dependencies here match requirements.txt
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 21.9b0
hooks:
- id: black
args:
- --diff
- --check
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
rev: 4.0.1
hooks:
- id: flake8
- repo: https://github.com/PyCQA/pylint
rev: v2.8.3
rev: v2.11.1
hooks:
- id: pylint
files: ^(telegram|examples)/.*\.py$
Expand All @@ -27,12 +27,17 @@ repos:
- cachetools==4.2.2
- . # this basically does `pip install -e .`
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.812
rev: v0.910
hooks:
- id: mypy
name: mypy-ptb
files: ^telegram/.*\.py$
additional_dependencies:
- types-ujson
- types-pytz
- types-cryptography
- types-certifi
- types-cachetools
- certifi
- tornado>=6.1
- APScheduler==3.6.3
Expand All @@ -51,9 +56,9 @@ repos:
- cachetools==4.2.2
- . # this basically does `pip install -e .`
- repo: https://github.com/asottile/pyupgrade
rev: v2.19.1
rev: v2.29.0
hooks:
- id: pyupgrade
files: ^(telegram|examples|tests)/.*\.py$
args:
- --py36-plus
- --py37-plus
4 changes: 4 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `DonalDuck004 <https://github.com/DonalDuck004>`_
- `Eana Hufwe <https://github.com/blueset>`_
- `Ehsan Online <https://github.com/ehsanonline>`_
- `Eldad Carin <https://github.com/eldbud>`_
- `Eli Gao <https://github.com/eligao>`_
- `Emilio Molinari <https://github.com/xates>`_
- `ErgoZ Riftbit Vaper <https://github.com/ergoz>`_
Expand All @@ -67,6 +68,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Joscha Götzer <https://github.com/Rostgnom>`_
- `jossalgon <https://github.com/jossalgon>`_
- `JRoot3D <https://github.com/JRoot3D>`_
- `kennethcheo <https://github.com/kennethcheo>`_
- `Kirill Vasin <https://github.com/vasinkd>`_
- `Kjwon15 <https://github.com/kjwon15>`_
- `Li-aung Yip <https://github.com/LiaungYip>`_
Expand All @@ -90,6 +92,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Patrick Hofmann <https://github.com/PH89>`_
- `Paul Larsen <https://github.com/PaulSonOfLars>`_
- `Pieter Schutz <https://github.com/eldinnie>`_
- `Piraty <https://github.com/piraty>`_
- `Poolitzer <https://github.com/Poolitzer>`_
- `Pranjalya Tiwari <https://github.com/Pranjalya>`_
- `Rahiel Kasim <https://github.com/rahiel>`_
Expand All @@ -111,5 +114,6 @@ The following wonderful people contributed directly or indirectly to this projec
- `wjt <https://github.com/wjt>`_
- `zeroone2numeral2 <https://github.com/zeroone2numeral2>`_
- `zeshuaro <https://github.com/zeshuaro>`_
- `zpavloudis <https://github.com/zpavloudis>`_

Please add yourself here alphabetically when you submit your first pull request.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Introduction

This library provides a pure Python interface for the
`Telegram Bot API <https://core.telegram.org/bots/api>`_.
It's compatible with Python versions 3.6.8+. PTB might also work on `PyPy <http://pypy.org/>`_, though there have been a lot of issues before. Hence, PyPy is not officially supported.
It's compatible with Python versions **3.7+**. PTB might also work on `PyPy <http://pypy.org/>`_, though there have been a lot of issues before. Hence, PyPy is not officially supported.

In addition to the pure API implementation, this library features a number of high-level classes to
make the development of bots easy and straightforward. These classes are contained in the
Expand Down Expand Up @@ -144,7 +144,7 @@ Optional Dependencies
PTB can be installed with optional dependencies:

* ``pip install python-telegram-bot[passport]`` installs the `cryptography <https://cryptography.io>`_ library. Use this, if you want to use Telegram Passport related functionality.
* ``pip install python-telegram-bot[ujson]`` installs the `ujson <https://pypi.org/project/ujson/>`_ library. It will then be used for JSON de- & encoding, which can bring speed up compared to the standard `json <https://docs.python.org/3/library/json.html>`_ library.
* ``pip install python-telegram-bot[json]`` installs the `ujson <https://pypi.org/project/ujson/>`_ library. It will then be used for JSON de- & encoding, which can bring speed up compared to the standard `json <https://docs.python.org/3/library/json.html>`_ library.
* ``pip install python-telegram-bot[socks]`` installs the `PySocks <https://pypi.org/project/PySocks/>`_ library. Use this, if you want to work behind a Socks5 server.

===============
Expand Down
4 changes: 2 additions & 2 deletions README_RAW.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Introduction

This library provides a pure Python, lightweight interface for the
`Telegram Bot API <https://core.telegram.org/bots/api>`_.
It's compatible with Python versions 3.6.8+. PTB-Raw might also work on `PyPy <http://pypy.org/>`_, though there have been a lot of issues before. Hence, PyPy is not officially supported.
It's compatible with Python versions **3.7+**. PTB-Raw might also work on `PyPy <http://pypy.org/>`_, though there have been a lot of issues before. Hence, PyPy is not officially supported.

``python-telegram-bot-raw`` is part of the `python-telegram-bot <https://python-telegram-bot.org>`_ ecosystem and provides the pure API functionality extracted from PTB. It therefore does *not* have independent release schedules, changelogs or documentation. Please consult the PTB resources.

Expand Down Expand Up @@ -144,7 +144,7 @@ Optional Dependencies
PTB can be installed with optional dependencies:

* ``pip install python-telegram-bot-raw[passport]`` installs the `cryptography <https://cryptography.io>`_ library. Use this, if you want to use Telegram Passport related functionality.
* ``pip install python-telegram-bot-raw[ujson]`` installs the `ujson <https://pypi.org/project/ujson/>`_ library. It will then be used for JSON de- & encoding, which can bring speed up compared to the standard `json <https://docs.python.org/3/library/json.html>`_ library.
* ``pip install python-telegram-bot-raw[json]`` installs the `ujson <https://pypi.org/project/ujson/>`_ library. It will then be used for JSON de- & encoding, which can bring speed up compared to the standard `json <https://docs.python.org/3/library/json.html>`_ library.

===============
Getting started
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx==3.5.4
sphinx==4.2.0
sphinx-pypi-upload
# When bumping this, make sure to rebuild the dark-mode CSS
# More instructions at source/_static/dark.css
Expand Down
Loading