Skip to content
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

Asyncio #2731

Merged
merged 171 commits into from Apr 24, 2022
Merged

Asyncio #2731

Show file tree
Hide file tree
Changes from 147 commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
f52a96d
Single, squashed commit
Bibo-Joshi Feb 6, 2022
ea70388
Get CH to roughly work
Bibo-Joshi Feb 8, 2022
c8b114f
Merge branch 'v14' into asyncio
Bibo-Joshi Feb 9, 2022
362e7b2
Start fixing some sphinx warnings
Bibo-Joshi Feb 9, 2022
ecd909d
More reference fixes
Bibo-Joshi Feb 9, 2022
d0565fc
Try fixing wrong source links on RTD
Bibo-Joshi Feb 10, 2022
985d24f
Slowly get started on request tests
Bibo-Joshi Feb 10, 2022
916fc20
More request tests
Bibo-Joshi Feb 12, 2022
c6b898a
Add two comments
Bibo-Joshi Feb 12, 2022
3008aad
Rework persistence logic
Bibo-Joshi Feb 13, 2022
f44ec18
Change pool timeout logic in HTTPXRequest
Bibo-Joshi Feb 14, 2022
6dbafc2
Handle unknown RequestResponse paramas
Bibo-Joshi Feb 15, 2022
6541090
Work on TrackingDict + tests
Bibo-Joshi Feb 15, 2022
fb76b4f
Re-add test_callbackdatacache.py
Bibo-Joshi Feb 15, 2022
70820ea
re-add test_filters.py
Bibo-Joshi Feb 15, 2022
1f564e3
Try fixing stuck CI
Bibo-Joshi Feb 16, 2022
d3d99cf
Get started on builder tests
Bibo-Joshi Feb 16, 2022
ac07df1
Builder tests
Bibo-Joshi Feb 17, 2022
ff04f65
Builder tests
Bibo-Joshi Feb 17, 2022
21c7cb7
Builder tests finished
Bibo-Joshi Feb 18, 2022
b7d007f
rename a file
Bibo-Joshi Feb 18, 2022
683edf6
Get started on updater tests
Bibo-Joshi Feb 20, 2022
01cb345
One more test & some code simplifications
Bibo-Joshi Feb 22, 2022
aa8ea12
Tests for Updater.start_polling
Bibo-Joshi Feb 22, 2022
884eb4e
First webhook test
Bibo-Joshi Feb 23, 2022
f55ab05
test arbitrary callback data
Bibo-Joshi Feb 24, 2022
d4d28f5
test webhooks with ssl
Bibo-Joshi Feb 24, 2022
29a2860
Another test
Bibo-Joshi Feb 24, 2022
c9180fa
adjust ssl handling in webhooks
Bibo-Joshi Feb 25, 2022
8b4aa7a
Finish Updater tests
Bibo-Joshi Feb 25, 2022
f262457
Try fixing existing tests
Bibo-Joshi Feb 26, 2022
a4080a4
Try harder
Bibo-Joshi Feb 26, 2022
e2a3907
Get started on application tests
Bibo-Joshi Feb 26, 2022
88978ff
Improve & tests logic if initializing, shutdown, start & stop
Bibo-Joshi Feb 26, 2022
254a65e
Further improve & test logic if initializing, shutdown, start & stop
Bibo-Joshi Feb 27, 2022
f3671fe
Few more application tests
Bibo-Joshi Feb 28, 2022
1ac116e
Few more application tests
Bibo-Joshi Mar 1, 2022
d6f95a9
fix updater tests
Bibo-Joshi Mar 2, 2022
af42aaf
More application tests - move tests for persistence integration into …
Bibo-Joshi Mar 6, 2022
611c780
Merge remote-tracking branch 'origin/asyncio' into asyncio
Bibo-Joshi Mar 6, 2022
a7b5fbd
jobqueue tests - jk, it's still application tests
Bibo-Joshi Mar 6, 2022
59c96fa
you guessed it: application tests
Bibo-Joshi Mar 7, 2022
ddf4bb3
Fix tests
Bibo-Joshi Mar 7, 2022
ed0ae0a
Simplify a type hint
Bibo-Joshi Mar 9, 2022
30bf475
Test run_polling/updater
Bibo-Joshi Mar 9, 2022
74aab4c
Merge remote-tracking branch 'origin/asyncio' into asyncio
Bibo-Joshi Mar 9, 2022
24dc3e6
skip more tests on windows
Bibo-Joshi Mar 10, 2022
8ab79f3
Small fix for applicationbuilder
Bibo-Joshi Mar 10, 2022
c97a532
Test a few more edge cases for application
Bibo-Joshi Mar 10, 2022
272da63
Make test suit run on PRs against asyncio branch
Bibo-Joshi Mar 10, 2022
b130115
Remove doubled assertion
Bibo-Joshi Mar 10, 2022
9a347ca
Slowly get started on testing persistence integration
Bibo-Joshi Mar 10, 2022
83d7367
also test conversationhandler-persistence-integration
Bibo-Joshi Mar 10, 2022
98d35af
Actually write some tests
Bibo-Joshi Mar 10, 2022
d6c8652
Small fix for persistence init
Bibo-Joshi Mar 10, 2022
6bc2abd
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 10, 2022
988b300
More persistence integration tests
Bibo-Joshi Mar 11, 2022
5509d71
fix smaller bugs that surfaced while testing persistence integration
Bibo-Joshi Mar 11, 2022
2d2a287
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 11, 2022
464253f
Review + according tests
Bibo-Joshi Mar 12, 2022
0094683
Merge branch 'v14' into asyncio
Bibo-Joshi Mar 12, 2022
14e4277
Try fixing tests
Bibo-Joshi Mar 12, 2022
b2a7520
Try harder
Bibo-Joshi Mar 12, 2022
dd761be
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 12, 2022
326117a
rename test_persistence_integration.py to test_basepersistence.py
Bibo-Joshi Mar 12, 2022
037f53c
Add some basic BasePersistence tests & adjust to the dropped replace…
Bibo-Joshi Mar 12, 2022
82bfb01
Try stabilizing on macOS
Bibo-Joshi Mar 13, 2022
cb7934e
Try again
Bibo-Joshi Mar 13, 2022
8fd6659
Test drop/migrate data
Bibo-Joshi Mar 13, 2022
a3f15f9
Add a convenience utility to conftest
Bibo-Joshi Mar 13, 2022
4122450
test Updater.start_* return value
Bibo-Joshi Mar 15, 2022
9e6c4d8
Large parts of review
Bibo-Joshi Mar 17, 2022
cee0d3c
More review
Bibo-Joshi Mar 18, 2022
7546bbf
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 18, 2022
234858c
make meta-tests path-agnostic
Bibo-Joshi Mar 18, 2022
3ef4d67
fix join request test
Bibo-Joshi Mar 18, 2022
745bfd1
Remove a sleep
Bibo-Joshi Mar 18, 2022
02940bb
revert catching cancelledError on polling stop
Bibo-Joshi Mar 18, 2022
baddee6
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 18, 2022
257b161
Adjust tests for now bahvior of adding ConversationHandler after init
Bibo-Joshi Mar 19, 2022
38df2b7
Allow App.process_update only after App. initialize was called
Bibo-Joshi Mar 19, 2022
89ba4a4
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 19, 2022
aa864e9
adjust tests
Bibo-Joshi Mar 19, 2022
27d439a
Fix run_* tests on non-windows
Bibo-Joshi Mar 19, 2022
2e897f0
Review
Bibo-Joshi Mar 22, 2022
af8a57a
More review
Bibo-Joshi Mar 22, 2022
7ae7d48
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 22, 2022
0996559
Change error types
Bibo-Joshi Mar 22, 2022
7a60432
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 22, 2022
ab891d1
adjust tests
Bibo-Joshi Mar 22, 2022
7672789
Two more BP tests
Bibo-Joshi Mar 23, 2022
43ede97
fix a test
Bibo-Joshi Mar 23, 2022
bdef5fd
one more BP test
Bibo-Joshi Mar 23, 2022
b3564c2
review
Bibo-Joshi Mar 23, 2022
79de11c
Remove remaining threading logic
Bibo-Joshi Mar 24, 2022
476a68d
Add notes on testing CH-BP integration and postpone that for now
Bibo-Joshi Mar 24, 2022
cae4e18
Test CallbackContext
Bibo-Joshi Mar 24, 2022
f90cd50
Test Defaults
Bibo-Joshi Mar 24, 2022
6012501
Get started on JobQueue Tests - half of them is still failing
Bibo-Joshi Mar 24, 2022
cc46bbf
Make JobQueue.start asyncio
Bibo-Joshi Mar 24, 2022
68e3471
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 24, 2022
ececf9f
adjust tests
Bibo-Joshi Mar 24, 2022
06ebc12
Merge remote-tracking branch 'origin/asyncio' into asyncio
Bibo-Joshi Mar 24, 2022
138ba20
finish up job_queue tests
Bibo-Joshi Mar 25, 2022
363bfef
some JQ tweaks
Bibo-Joshi Mar 25, 2022
901b936
Merge branch 'asyncio' into asyncio-tests
Bibo-Joshi Mar 25, 2022
a852ec6
Test all handles except for CH
Bibo-Joshi Mar 26, 2022
346ac17
fix the test suite
Bibo-Joshi Mar 26, 2022
424f810
small tweak in DictPersistence
Bibo-Joshi Mar 27, 2022
d9e0eda
Try to improve non-blocking logic of CH
Bibo-Joshi Mar 30, 2022
2fc5eeb
Remove some resolved todo items
Bibo-Joshi Mar 30, 2022
737e013
some more
Bibo-Joshi Mar 30, 2022
d14e55d
fix a typo
Bibo-Joshi Mar 30, 2022
0f69b02
Rename App.dispatch_error to App.process_error
Bibo-Joshi Apr 1, 2022
e31419c
fix a bug in persisting non-blocking conversations
Bibo-Joshi Apr 1, 2022
d189ce3
Review
Bibo-Joshi Apr 3, 2022
a4b37fd
Small adjustments for persistence
Bibo-Joshi Apr 3, 2022
a0204c6
Fix persistence of nested conversations
Bibo-Joshi Apr 3, 2022
655d080
Remove unused method from webhook setup
Bibo-Joshi Apr 3, 2022
c99645e
Review
Bibo-Joshi Apr 4, 2022
40f886b
more adjusting
Bibo-Joshi Apr 4, 2022
02f3bf3
Review
Bibo-Joshi Apr 5, 2022
ed2a39e
Make CH.persistent immutable
Bibo-Joshi Apr 5, 2022
9891fd4
Merge remote-tracking branch 'origin/asyncio' into asyncio
Bibo-Joshi Apr 5, 2022
51b4044
typo
Bibo-Joshi Apr 7, 2022
1a16bda
Remove falsely committed debug print
Bibo-Joshi Apr 8, 2022
92e2cdd
Review
Bibo-Joshi Apr 10, 2022
62fc4ff
Updating the examples (#2937)
Poolitzer Apr 10, 2022
8411d62
log errors in Update.de_json in Updater
Bibo-Joshi Apr 10, 2022
59e0c0a
Merge remote-tracking branch 'origin/asyncio' into asyncio
Bibo-Joshi Apr 10, 2022
c116f2e
Stabilize startup of App.run()
Bibo-Joshi Apr 12, 2022
43ca1da
Add another warning about CH timeout not working if JQ is not running
Bibo-Joshi Apr 12, 2022
87e977f
change blocking-resolution order in CH
Bibo-Joshi Apr 16, 2022
ef4bc43
small fix
Bibo-Joshi Apr 16, 2022
c46fcdd
Docs/CSI for asyncio (#2926)
harshil21 Apr 17, 2022
e8fdd13
Asyncio Tests (#2936)
Bibo-Joshi Apr 17, 2022
bafd4ed
pre-commit
Bibo-Joshi Apr 17, 2022
0c9be83
some typos, wording etc
Bibo-Joshi Apr 17, 2022
696e622
Apply black style to code blocks in docs
Bibo-Joshi Apr 17, 2022
b0605a7
avoid the term "asynchronously"
Bibo-Joshi Apr 17, 2022
6938ed8
Some docstring improvements for app
Bibo-Joshi Apr 17, 2022
6828757
Fix a warning on custom CC attributes
Bibo-Joshi Apr 17, 2022
ec784a7
Improve usage of AbstractAsyncContextManager
Bibo-Joshi Apr 17, 2022
26b0dc4
Some versioning directives
Bibo-Joshi Apr 17, 2022
d7ff692
fix tests
Bibo-Joshi Apr 17, 2022
d7b9643
small edits for tests
Bibo-Joshi Apr 17, 2022
b6eef7e
Review
Bibo-Joshi Apr 17, 2022
c61afc8
Update timerbot a bit
Bibo-Joshi Apr 17, 2022
70ee0ff
shutdown with signal handlers
Bibo-Joshi Apr 17, 2022
54c83dc
try improving tests
Bibo-Joshi Apr 17, 2022
b8f41a5
try again
Bibo-Joshi Apr 17, 2022
0a83834
One last try
Bibo-Joshi Apr 17, 2022
193c435
fix some docs of HTTPXRequest
Bibo-Joshi Apr 18, 2022
079fca1
move definition of InitAppBuilder type alias to bottom of file
harshil21 Apr 18, 2022
a1bf431
try to make codacy happy w.r.t hardcoded token in example
harshil21 Apr 18, 2022
74bf2df
add a debug print to failing test
Bibo-Joshi Apr 18, 2022
bd8fe9e
try fixing the failing test
Bibo-Joshi Apr 18, 2022
a7a11bc
create_task while not running: warn instead of log
Bibo-Joshi Apr 18, 2022
9a541f0
second try for failing test
Bibo-Joshi Apr 18, 2022
c7677c2
tiny doc fix
Bibo-Joshi Apr 19, 2022
b4fa728
Another small doc fix
Bibo-Joshi Apr 19, 2022
12f1322
jobqueue doc fixes
harshil21 Apr 20, 2022
bafe934
Rework uploading files - tests for RequestData are not yet adjusted
Bibo-Joshi Apr 21, 2022
f36aafb
Merge remote-tracking branch 'origin/asyncio' into asyncio
Bibo-Joshi Apr 21, 2022
0086ad5
doc adjustments
Bibo-Joshi Apr 22, 2022
1aa2fc1
Test RequestData
Bibo-Joshi Apr 22, 2022
f1f7e24
document a limit about send_document/voice
harshil21 Apr 22, 2022
88b8e19
Fix: Small doc fixes + improvements
Poolitzer Apr 23, 2022
58c7781
forgot to commit review
Bibo-Joshi Apr 24, 2022
66d9a13
fix pre-commit
Bibo-Joshi Apr 24, 2022
9389bc9
finally fix certificate passing
Bibo-Joshi Apr 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .deepsource.toml
Expand Up @@ -5,7 +5,6 @@ test_patterns = ["tests/**"]
exclude_patterns = [
"tests/**",
"docs/**",
"telegram/vendor/**",
"setup.py",
"setup-raw.py"
]
Expand Down
11 changes: 3 additions & 8 deletions .github/CONTRIBUTING.rst
Expand Up @@ -153,12 +153,6 @@ Here's how to make a one-off code change.
$ git commit -a
$ git push origin your-branch-name

- If after merging you see local modified files in ``telegram/vendor/`` directory, that you didn't actually touch, that means you need to update submodules with this command:

.. code-block:: bash

$ git submodule update --init --recursive

- At the end, the reviewer will merge the pull request.

6. **Tidy up!** Delete the feature branch from both your local clone and the GitHub repository:
Expand Down Expand Up @@ -260,11 +254,12 @@ break the API classes. For example:

# GOOD
def __init__(self, id, name, last_name=None, **kwargs):
self.last_name = last_name
self.last_name = last_name


# BAD
def __init__(self, id, name, last_name=None):
self.last_name = last_name
self.last_name = last_name


.. _`Code of Conduct`: https://www.python.org/psf/codeofconduct/
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Expand Up @@ -8,7 +8,7 @@ Hey! You're PRing? Cool! Please have a look at the below checklist. It's here to
- [ ] 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)
- [ ] Added new classes & modules to the docs
- [ ] Added new classes & modules to the docs and all suitable `__all__` s


### If the PR contains API changes (otherwise, you can delete this passage)
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/test.yml
Expand Up @@ -20,9 +20,6 @@ jobs:
fail-fast: False
steps:
- uses: actions/checkout@v2
- name: Initialize vendored libs
run:
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -77,9 +74,6 @@ jobs:
fail-fast: False
steps:
- uses: actions/checkout@v2
- name: Initialize vendored libs
run:
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -106,9 +100,6 @@ jobs:
fail-fast: False
steps:
- uses: actions/checkout@v2
- name: Initialize vendored libs
run:
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

31 changes: 16 additions & 15 deletions .pre-commit-config.yaml
Expand Up @@ -9,6 +9,8 @@ repos:
args:
- --diff
- --check
additional_dependencies:
- click==8.0.2
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
hooks:
Expand All @@ -23,7 +25,7 @@ repos:
# run pylint across multiple cpu cores to speed it up-
- --jobs=0 # See https://pylint.pycqa.org/en/latest/user_guide/run.html?#parallel-execution to know more
additional_dependencies:
- certifi
- httpx >= 0.20.0,<1.0
- tornado>=6.1
- APScheduler==3.6.3
- cachetools==4.2.2
Expand All @@ -38,25 +40,24 @@ repos:
- types-ujson
- types-pytz
- types-cryptography
- types-certifi
- types-cachetools
- certifi
- tornado>=6.1
- APScheduler==3.6.3
- cachetools==4.2.2
- . # this basically does `pip install -e .`
- id: mypy
name: mypy-examples
files: ^examples/.*\.py$
args:
- --no-strict-optional
- --follow-imports=silent
additional_dependencies:
- certifi
- httpx >= 0.20.0,<1.0
- tornado>=6.1
- APScheduler==3.6.3
- cachetools==4.2.2
- . # this basically does `pip install -e .`
- id: mypy
name: mypy-examples
files: ^examples/.*\.py$
args:
- --no-strict-optional
- --follow-imports=silent
additional_dependencies:
- certifi
- tornado>=6.1
- APScheduler==3.6.3
- cachetools==4.2.2
- . # this basically does `pip install -e .`
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
hooks:
Expand Down
7 changes: 0 additions & 7 deletions AUTHORS.rst
Expand Up @@ -14,13 +14,6 @@ Emeritus maintainers include
`Jannes Höke <https://github.com/jh0ker>`_ (`@jh0ker <https://t.me/jh0ker>`_ on Telegram),
`Noam Meltzer <https://github.com/tsnoam>`_, `Pieter Schutz <https://github.com/eldinnie>`_ and `Jasmin Bom <https://github.com/jsmnbom>`_.

Vendored packages
-----------------

We're vendoring urllib3 as part of ``python-telegram-bot`` which is distributed under the MIT
license. For more info, full credits & license terms, the sources can be found here:
`https://github.com/python-telegram-bot/urllib3`.

Contributors
------------

Expand Down
26 changes: 18 additions & 8 deletions README.rst
Expand Up @@ -113,6 +113,20 @@ Telegram API support

All types and methods of the Telegram Bot API **5.7** are supported.

===========
Concurrency
===========
harshil21 marked this conversation as resolved.
Show resolved Hide resolved

Since v14.0, ``python-telegram-bot`` is built on top of Pythons ``asyncio`` module.
Because ``asyncio`` is in general single-threaded, ``python-telegram-bot`` does currently not aim to be thread-safe.
Noteworthy parts of ``python-telegram-bots`` API that are likely to cause issues (e.g. race conditions) when used in a multi-threaded setting include:

* ``telegram.ext.Application/Updater.update_queue``
* ``telegram.ext.ConversationHandler.check/handle_update``
* ``telegram.ext.CallbackDataCache``
* ``telegram.ext.BasePersistence``
* all classes in the ``telegram.ext.filters`` module that allow to add/remove allowed users/chats at runtime

==========
Installing
==========
Expand All @@ -130,12 +144,6 @@ Or you can install from source with:
$ git clone https://github.com/python-telegram-bot/python-telegram-bot --recursive
$ cd python-telegram-bot
$ python setup.py install

In case you have a previously cloned local repository already, you should initialize the added urllib3 submodule before installing with:

.. code:: shell

$ git submodule update --init --recursive

---------------------
Optional Dependencies
Expand Down Expand Up @@ -182,8 +190,10 @@ This library uses the ``logging`` module. To set up logging to standard output,
.. code:: python

import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)

at the beginning of your script.

Expand Down
19 changes: 11 additions & 8 deletions README_RAW.rst
Expand Up @@ -107,6 +107,13 @@ Telegram API support

All types and methods of the Telegram Bot API **5.7** are supported.

===========
Concurrency
===========

Since v14.0, ``python-telegram-bot`` is built on top of Pythons ``asyncio`` module.
Because ``asyncio`` is in general single-threaded, ``python-telegram-bot`` does currently not aim to be thread-safe.

==========
Installing
==========
Expand All @@ -125,12 +132,6 @@ Or you can install from source with:
$ cd python-telegram-bot
$ python setup-raw.py install

In case you have a previously cloned local repository already, you should initialize the added urllib3 submodule before installing with:

.. code:: shell

$ git submodule update --init --recursive

----
Note
----
Expand Down Expand Up @@ -164,8 +165,10 @@ This library uses the ``logging`` module. To set up logging to standard output,
.. code:: python

import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)

at the beginning of your script.

Expand Down
39 changes: 23 additions & 16 deletions docs/source/conf.py
Expand Up @@ -127,6 +127,9 @@
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# Decides the language used for syntax highlighting of code blocks.
highlight_language = 'python3'

# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

Expand Down Expand Up @@ -453,10 +456,14 @@ def _git_branch() -> str:
"""Get's the current git sha if available or fall back to `master`"""
try:
output = subprocess.check_output( # skipcq: BAN-B607
["git", "describe", "--tags"], stderr=subprocess.STDOUT
["git", "describe", "--tags", "--always"], stderr=subprocess.STDOUT
)
return output.decode().strip()
except Exception:
except Exception as exc:
sphinx_logger.exception(
f'Failed to get a description of the current commit. Falling back to `master`.',
exc_info=exc
)
return 'master'


Expand Down Expand Up @@ -521,24 +528,24 @@ def autodoc_process_bases(app, name, obj, option, bases: list):
bases[idx] = f':class:`{base}`'

# Now convert `telegram._message.Message` to `telegram.Message` etc
match = re.search(pattern=r"(telegram(\.ext|))\.", string=base)
if match and '_utils' not in base:
base = base.rstrip("'>")
parts = base.rsplit(".", maxsplit=2)
match = re.search(pattern=r"(telegram(\.ext|))\.[_\w\.]+", string=base)
if not match or '_utils' in base:
return

# Replace private base classes with their respective parent
parts[-1] = PRIVATE_BASE_CLASSES.get(parts[-1], parts[-1])
parts = match.group(0).split(".")

# To make sure that e.g. `telegram.ext.filters.BaseFilter` keeps the `filters` part
if not parts[-2].startswith('_') and '_' not in parts[0]:
base = '.'.join(parts[-2:])
else:
base = parts[-1]
# Remove private paths
for index, part in enumerate(parts):
if part.startswith("_"):
parts = parts[:index] + parts[-1:]
break

# add `telegram(.ext).` back in front
base = f'{match.group(0)}{base}'
# Replace private base classes with their respective parent
parts = [PRIVATE_BASE_CLASSES.get(part, part) for part in parts]

bases[idx] = f':class:`{base}`'
base = ".".join(parts)

bases[idx] = f':class:`{base}`'


def setup(app: Sphinx):
Expand Down
8 changes: 8 additions & 0 deletions docs/source/telegram.ext.application.rst
@@ -0,0 +1,8 @@
:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/_application.py

telegram.ext.Application
========================

.. autoclass:: telegram.ext.Application
:members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/telegram.ext.applicationbuilder.rst
@@ -0,0 +1,7 @@
:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/_applicationbuilder.py

telegram.ext.ApplicationBuilder
===============================

.. autoclass:: telegram.ext.ApplicationBuilder
:members:
8 changes: 8 additions & 0 deletions docs/source/telegram.ext.applicationhandlerstop.rst
@@ -0,0 +1,8 @@
:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/ext/_application.py

telegram.ext.ApplicationHandlerStop
===================================

.. autoclass:: telegram.ext.ApplicationHandlerStop
:members:
:show-inheritance:
8 changes: 0 additions & 8 deletions docs/source/telegram.ext.dispatcher.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/telegram.ext.dispatcherbuilder.rst

This file was deleted.

8 changes: 0 additions & 8 deletions docs/source/telegram.ext.dispatcherhandlerstop.rst

This file was deleted.

7 changes: 3 additions & 4 deletions docs/source/telegram.ext.rst
Expand Up @@ -4,11 +4,10 @@ telegram.ext package
.. toctree::

telegram.ext.extbot
telegram.ext.updaterbuilder
telegram.ext.applicationbuilder
telegram.ext.application
telegram.ext.applicationhandlerstop
telegram.ext.updater
telegram.ext.dispatcherbuilder
telegram.ext.dispatcher
telegram.ext.dispatcherhandlerstop
telegram.ext.callbackcontext
telegram.ext.job
telegram.ext.jobqueue
Expand Down
7 changes: 0 additions & 7 deletions docs/source/telegram.ext.updaterbuilder.rst

This file was deleted.

8 changes: 8 additions & 0 deletions docs/source/telegram.request.baserequest.rst
@@ -0,0 +1,8 @@
:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/request/_baserequest.py

telegram.request.BaseRequest
============================

.. autoclass:: telegram.request.BaseRequest
:members:
:show-inheritance:
8 changes: 8 additions & 0 deletions docs/source/telegram.request.httpxrequest.rst
@@ -0,0 +1,8 @@
:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/request/_httpxrequest.py

telegram.request.HTTPXRequest
=============================

.. autoclass:: telegram.request.HTTPXRequest
:members:
:show-inheritance: