GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Switch to `asyncio` (#2731) · MSutt/python-telegram-bot@42eaa67

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .deepsource.toml
  • .github
    • CONTRIBUTING.rst
    • pull_request_template.md
    • workflows
      • test.yml
  • .gitmodules
  • .pre-commit-config.yaml
  • AUTHORS.rst
  • README.rst
  • README_RAW.rst
  • docs/source
    • conf.py
    • index.rst
    • telegram.ext.application.rst
    • telegram.ext.applicationbuilder.rst
    • telegram.ext.applicationhandlerstop.rst
    • telegram.ext.dispatcher.rst
    • telegram.ext.dispatcherbuilder.rst
    • telegram.ext.dispatcherhandlerstop.rst
    • telegram.ext.rst
    • telegram.ext.updaterbuilder.rst
    • telegram.request.baserequest.rst
    • telegram.request.httpxrequest.rst
    • telegram.request.requestdata.rst
    • telegram.request.rst
  • examples
    • arbitrarycallbackdatabot.py
    • chatmemberbot.py
    • contexttypesbot.py
    • conversationbot.py
    • conversationbot2.py
    • deeplinking.py
    • echobot.py
    • errorhandlerbot.py
    • inlinebot.py
    • inlinekeyboard.py
    • inlinekeyboard2.py
    • nestedconversationbot.py
    • passportbot.html
    • passportbot.py
    • paymentbot.py
    • persistentconversationbot.py
    • pollbot.py
    • rawapibot.py
    • timerbot.py
  • pyproject.toml
  • requirements-dev.txt
  • requirements.txt
  • setup.cfg
  • setup.py
  • telegram
    • __main__.py
    • _bot.py
    • _callbackquery.py
    • _chat.py
    • _chatjoinrequest.py
    • _chatmemberupdated.py
    • _choseninlineresult.py
    • _files
      • _basemedium.py
      • _basethumbedmedium.py
      • chatphoto.py
      • file.py
      • inputfile.py
      • inputmedia.py
      • sticker.py
      • video.py
    • _games
      • game.py
    • _inline
      • inlinequery.py
    • _message.py
    • _passport
      • passportfile.py
    • _payment
      • precheckoutquery.py
      • shippingquery.py
    • _replykeyboardmarkup.py
    • _update.py
    • _user.py
    • _userprofilephotos.py
    • _utils
      • datetime.py
      • defaultvalue.py
      • enum.py
      • files.py
      • types.py
    • constants.py
    • error.py
    • ext
      • __init__.py
      • _application.py
      • _applicationbuilder.py
      • _basepersistence.py
      • _builders.py
      • _callbackcontext.py
      • _callbackdatacache.py
      • _callbackqueryhandler.py
      • _chatjoinrequesthandler.py
      • _chatmemberhandler.py
      • _choseninlineresulthandler.py
      • _commandhandler.py
      • _contexttypes.py
      • _conversationhandler.py
      • _defaults.py
      • _dictpersistence.py
      • _dispatcher.py
      • _extbot.py
      • _handler.py
      • _inlinequeryhandler.py
      • _jobqueue.py
      • _messagehandler.py
      • _picklepersistence.py
      • _pollanswerhandler.py
      • _pollhandler.py
      • _precheckoutqueryhandler.py
      • _shippingqueryhandler.py
      • _stringcommandhandler.py
      • _stringregexhandler.py
      • _typehandler.py
      • _updater.py
      • _utils
        • promise.py
        • stack.py
        • trackingdict.py
        • types.py
        • webhookhandler.py
      • filters.py
    • helpers.py
    • request.py
    • request
      • __init__.py
      • _baserequest.py
      • _httpxrequest.py
      • _requestdata.py
      • _requestparameter.py
    • vendor
      • __init__.py
      • ptb_urllib3
  • tests
    • bots.py
    • conftest.py
    • data
      • sslcert.key
      • sslcert.pem
      • text_file.txt
    • test_animation.py
    • test_application.py
    • test_applicationbuilder.py
    • test_audio.py
    • test_basepersistence.py
    • test_bot.py
    • test_builders.py
    • test_callbackcontext.py
    • test_callbackquery.py
    • test_callbackqueryhandler.py
    • test_chat.py
    • test_chatjoinrequest.py
    • test_chatjoinrequesthandler.py
    • test_chatmemberhandler.py
    • test_chatphoto.py
    • test_choseninlineresulthandler.py
    • test_commandhandler.py
    • test_constants.py
    • test_contact.py
    • test_conversationhandler.py
    • test_defaults.py
    • test_dictpersistence.py
    • test_dispatcher.py
    • test_document.py
    • test_error.py
    • test_file.py
    • test_files.py
    • test_forcereply.py
    • test_gamehighscore.py
    • test_inlinekeyboardmarkup.py
    • test_inlinequery.py
    • test_inlinequeryhandler.py
    • test_inputfile.py
    • test_inputmedia.py
    • test_invoice.py
    • test_jobqueue.py
    • test_location.py
    • test_message.py
    • test_messagehandler.py
    • test_meta.py
    • test_official.py
    • test_passport.py
    • test_passportfile.py
    • test_persistence.py
    • test_photo.py
    • test_picklepersistence.py
    • test_poll.py
    • test_pollanswerhandler.py
    • test_pollhandler.py
    • test_precheckoutquery.py
    • test_precheckoutqueryhandler.py
    • test_promise.py
    • test_replykeyboardmarkup.py
    • test_replykeyboardremove.py
    • test_request.py
    • test_requestdata.py
    • test_requestparameter.py
    • test_shippingquery.py
    • test_shippingqueryhandler.py
    • test_slots.py
    • test_stack.py
    • test_sticker.py
    • test_stringcommandhandler.py
    • test_stringregexhandler.py
    • test_trackingdict.py
    • test_typehandler.py
    • test_updater.py
    • test_user.py
    • test_venue.py
    • test_video.py
    • test_videonote.py
    • test_voice.py
    • test_voicechat.py

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.deepsource.toml‎

Copy file name to clipboardExpand all lines: .deepsource.toml
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ test_patterns = ["tests/**"]
55
exclude_patterns = [
66
"tests/**",
77
"docs/**",
8-
"telegram/vendor/**",
98
"setup.py",
109
"setup-raw.py"
1110
]
Collapse file

‎.github/CONTRIBUTING.rst‎

Copy file name to clipboardExpand all lines: .github/CONTRIBUTING.rst
+3-8Lines changed: 3 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,6 @@ Here's how to make a one-off code change.
153153
$ git commit -a
154154
$ git push origin your-branch-name
155155
156-
- 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:
157-
158-
.. code-block:: bash
159-
160-
$ git submodule update --init --recursive
161-
162156
- At the end, the reviewer will merge the pull request.
163157

164158
6. **Tidy up!** Delete the feature branch from both your local clone and the GitHub repository:
@@ -260,11 +254,12 @@ break the API classes. For example:
260254
261255
# GOOD
262256
def __init__(self, id, name, last_name=None, **kwargs):
263-
self.last_name = last_name
257+
self.last_name = last_name
258+
264259
265260
# BAD
266261
def __init__(self, id, name, last_name=None):
267-
self.last_name = last_name
262+
self.last_name = last_name
268263
269264
270265
.. _`Code of Conduct`: https://www.python.org/psf/codeofconduct/
Collapse file

‎.github/pull_request_template.md‎

Copy file name to clipboardExpand all lines: .github/pull_request_template.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Hey! You're PRing? Cool! Please have a look at the below checklist. It's here to
88
- [ ] Created new or adapted existing unit tests
99
- [ ] Documented code changes according to the [CSI standard](https://standards.mousepawmedia.com/en/stable/csi.html)
1010
- [ ] Added myself alphabetically to `AUTHORS.rst` (optional)
11-
- [ ] Added new classes & modules to the docs
11+
- [ ] Added new classes & modules to the docs and all suitable `__all__` s
1212

1313

1414
### If the PR contains API changes (otherwise, you can delete this passage)
Collapse file

‎.github/workflows/test.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/test.yml
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ jobs:
1818
fail-fast: False
1919
steps:
2020
- uses: actions/checkout@v2
21-
- name: Initialize vendored libs
22-
run:
23-
git submodule update --init --recursive
2421
- name: Set up Python ${{ matrix.python-version }}
2522
uses: actions/setup-python@v2
2623
with:
@@ -75,9 +72,6 @@ jobs:
7572
fail-fast: False
7673
steps:
7774
- uses: actions/checkout@v2
78-
- name: Initialize vendored libs
79-
run:
80-
git submodule update --init --recursive
8175
- name: Set up Python ${{ matrix.python-version }}
8276
uses: actions/setup-python@v2
8377
with:
@@ -104,9 +98,6 @@ jobs:
10498
fail-fast: False
10599
steps:
106100
- uses: actions/checkout@v2
107-
- name: Initialize vendored libs
108-
run:
109-
git submodule update --init --recursive
110101
- name: Set up Python ${{ matrix.python-version }}
111102
uses: actions/setup-python@v2
112103
with:
Collapse file

‎.gitmodules‎

Copy file name to clipboardExpand all lines: .gitmodules
-4Lines changed: 0 additions & 4 deletions
This file was deleted.
Collapse file

‎.pre-commit-config.yaml‎

Copy file name to clipboardExpand all lines: .pre-commit-config.yaml
+16-15Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ repos:
99
args:
1010
- --diff
1111
- --check
12+
additional_dependencies:
13+
- click==8.0.2
1214
- repo: https://gitlab.com/pycqa/flake8
1315
rev: 4.0.1
1416
hooks:
@@ -23,7 +25,7 @@ repos:
2325
# run pylint across multiple cpu cores to speed it up-
2426
- --jobs=0 # See https://pylint.pycqa.org/en/latest/user_guide/run.html?#parallel-execution to know more
2527
additional_dependencies:
26-
- certifi
28+
- httpx >= 0.20.0,<1.0
2729
- tornado>=6.1
2830
- APScheduler==3.6.3
2931
- cachetools==4.2.2
@@ -38,25 +40,24 @@ repos:
3840
- types-ujson
3941
- types-pytz
4042
- types-cryptography
41-
- types-certifi
4243
- types-cachetools
43-
- certifi
44-
- tornado>=6.1
45-
- APScheduler==3.6.3
46-
- cachetools==4.2.2
47-
- . # this basically does `pip install -e .`
48-
- id: mypy
49-
name: mypy-examples
50-
files: ^examples/.*\.py$
51-
args:
52-
- --no-strict-optional
53-
- --follow-imports=silent
54-
additional_dependencies:
55-
- certifi
44+
- httpx >= 0.20.0,<1.0
5645
- tornado>=6.1
5746
- APScheduler==3.6.3
5847
- cachetools==4.2.2
5948
- . # this basically does `pip install -e .`
49+
- id: mypy
50+
name: mypy-examples
51+
files: ^examples/.*\.py$
52+
args:
53+
- --no-strict-optional
54+
- --follow-imports=silent
55+
additional_dependencies:
56+
- certifi
57+
- tornado>=6.1
58+
- APScheduler==3.6.3
59+
- cachetools==4.2.2
60+
- . # this basically does `pip install -e .`
6061
- repo: https://github.com/asottile/pyupgrade
6162
rev: v2.29.0
6263
hooks:
Collapse file

‎AUTHORS.rst‎

Copy file name to clipboardExpand all lines: AUTHORS.rst
-7Lines changed: 0 additions & 7 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ Emeritus maintainers include
1414
`Jannes Höke <https://github.com/jh0ker>`_ (`@jh0ker <https://t.me/jh0ker>`_ on Telegram),
1515
`Noam Meltzer <https://github.com/tsnoam>`_, `Pieter Schutz <https://github.com/eldinnie>`_ and `Jasmin Bom <https://github.com/jsmnbom>`_.
1616

17-
Vendored packages
18-
-----------------
19-
20-
We're vendoring urllib3 as part of ``python-telegram-bot`` which is distributed under the MIT
21-
license. For more info, full credits & license terms, the sources can be found here:
22-
`https://github.com/python-telegram-bot/urllib3`.
23-
2417
Contributors
2518
------------
2619

Collapse file

‎README.rst‎

Copy file name to clipboardExpand all lines: README.rst
+18-8Lines changed: 18 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ Telegram API support
113113

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

116+
===========
117+
Concurrency
118+
===========
119+
120+
Since v14.0, ``python-telegram-bot`` is built on top of Pythons ``asyncio`` module.
121+
Because ``asyncio`` is in general single-threaded, ``python-telegram-bot`` does currently not aim to be thread-safe.
122+
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:
123+
124+
* ``telegram.ext.Application/Updater.update_queue``
125+
* ``telegram.ext.ConversationHandler.check/handle_update``
126+
* ``telegram.ext.CallbackDataCache``
127+
* ``telegram.ext.BasePersistence``
128+
* all classes in the ``telegram.ext.filters`` module that allow to add/remove allowed users/chats at runtime
129+
116130
==========
117131
Installing
118132
==========
@@ -130,12 +144,6 @@ Or you can install from source with:
130144
$ git clone https://github.com/python-telegram-bot/python-telegram-bot --recursive
131145
$ cd python-telegram-bot
132146
$ python setup.py install
133-
134-
In case you have a previously cloned local repository already, you should initialize the added urllib3 submodule before installing with:
135-
136-
.. code:: shell
137-
138-
$ git submodule update --init --recursive
139147
140148
---------------------
141149
Optional Dependencies
@@ -182,8 +190,10 @@ This library uses the ``logging`` module. To set up logging to standard output,
182190
.. code:: python
183191
184192
import logging
185-
logging.basicConfig(level=logging.DEBUG,
186-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
193+
194+
logging.basicConfig(
195+
level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
196+
)
187197
188198
at the beginning of your script.
189199

Collapse file

‎README_RAW.rst‎

Copy file name to clipboardExpand all lines: README_RAW.rst
+11-8Lines changed: 11 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ Telegram API support
107107

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

110+
===========
111+
Concurrency
112+
===========
113+
114+
Since v14.0, ``python-telegram-bot`` is built on top of Pythons ``asyncio`` module.
115+
Because ``asyncio`` is in general single-threaded, ``python-telegram-bot`` does currently not aim to be thread-safe.
116+
110117
==========
111118
Installing
112119
==========
@@ -125,12 +132,6 @@ Or you can install from source with:
125132
$ cd python-telegram-bot
126133
$ python setup-raw.py install
127134
128-
In case you have a previously cloned local repository already, you should initialize the added urllib3 submodule before installing with:
129-
130-
.. code:: shell
131-
132-
$ git submodule update --init --recursive
133-
134135
----
135136
Note
136137
----
@@ -164,8 +165,10 @@ This library uses the ``logging`` module. To set up logging to standard output,
164165
.. code:: python
165166
166167
import logging
167-
logging.basicConfig(level=logging.DEBUG,
168-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
168+
169+
logging.basicConfig(
170+
level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
171+
)
169172
170173
at the beginning of your script.
171174

Collapse file

‎docs/source/conf.py‎

Copy file name to clipboardExpand all lines: docs/source/conf.py
+25-18Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@
127127
# The name of the Pygments (syntax highlighting) style to use.
128128
pygments_style = 'sphinx'
129129

130+
# Decides the language used for syntax highlighting of code blocks.
131+
highlight_language = 'python3'
132+
130133
# A list of ignored prefixes for module index sorting.
131134
#modindex_common_prefix = []
132135

@@ -155,7 +158,7 @@
155158
"announcement": 'PTB has undergone significant changes in v14. Please read the documentation '
156159
'carefully and also check out the transition guide in the '
157160
'<a href="https://github.com/python-telegram-bot/python-telegram-bot/wiki">'
158-
'wiki</a>',
161+
'wiki</a>.',
159162
}
160163

161164
# Add any paths that contain custom themes here, relative to this directory.
@@ -453,10 +456,14 @@ def _git_branch() -> str:
453456
"""Get's the current git sha if available or fall back to `master`"""
454457
try:
455458
output = subprocess.check_output( # skipcq: BAN-B607
456-
["git", "describe", "--tags"], stderr=subprocess.STDOUT
459+
["git", "describe", "--tags", "--always"], stderr=subprocess.STDOUT
457460
)
458461
return output.decode().strip()
459-
except Exception:
462+
except Exception as exc:
463+
sphinx_logger.exception(
464+
f'Failed to get a description of the current commit. Falling back to `master`.',
465+
exc_info=exc
466+
)
460467
return 'master'
461468

462469

@@ -510,7 +517,7 @@ def autodoc_process_bases(app, name, obj, option, bases: list):
510517
base = str(base)
511518

512519
# Special case because base classes are in std lib:
513-
if "_StringEnum" in base:
520+
if "StringEnum" in base == "<enum 'StringEnum'>":
514521
bases[idx] = ":class:`enum.Enum`"
515522
bases.insert(0, ':class:`str`')
516523
continue
@@ -521,24 +528,24 @@ def autodoc_process_bases(app, name, obj, option, bases: list):
521528
bases[idx] = f':class:`{base}`'
522529

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

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

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

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

541-
bases[idx] = f':class:`{base}`'
546+
base = ".".join(parts)
547+
548+
bases[idx] = f':class:`{base}`'
542549

543550

544551
def setup(app: Sphinx):

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.