Update and Expand Tests & pre-commit Settings and Improve Code Quality (#2925)

Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
This commit is contained in:
Harshil
2022-05-05 12:57:54 +05:30
committed by Hinrich Mahler
parent e10f9164fe
commit 335772568f
293 changed files with 1391 additions and 2208 deletions
+2 -2
View File
@@ -21,12 +21,12 @@ jobs:
os: [ubuntu-latest]
fail-fast: False
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Initialize vendored libs
run:
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
+5 -26
View File
@@ -20,9 +20,9 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: False
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
@@ -60,7 +60,7 @@ jobs:
shell: bash --noprofile --norc {0}
- name: Submit coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
env_vars: OS,PYTHON
name: ${{ matrix.os }}-${{ matrix.python-version }}
@@ -74,9 +74,9 @@ jobs:
os: [ubuntu-latest]
fail-fast: False
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
@@ -91,24 +91,3 @@ jobs:
env:
TEST_OFFICIAL: "true"
shell: bash --noprofile --norc {0}
test_pre_commit:
name: test-pre-commit
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: [3.7]
os: [ubuntu-latest]
fail-fast: False
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -W ignore -m pip install --upgrade pip
python -W ignore -m pip install -r requirements.txt
python -W ignore -m pip install -r requirements-dev.txt
- name: Run pre-commit tests
run: pre-commit run --all-files
+18 -7
View File
@@ -1,29 +1,34 @@
# Make sure that
# * the revs specified here match requirements-dev.txt
# * the additional_dependencies here match requirements.txt
ci:
autofix_prs: false
autoupdate_schedule: monthly
repos:
- repo: https://github.com/psf/black
rev: 21.9b0
rev: 22.3.0
hooks:
- id: black
args:
- --diff
- --check
additional_dependencies:
- click==8.0.2
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
- repo: https://github.com/PyCQA/pylint
rev: v2.12.1
rev: v2.13.8
hooks:
- id: pylint
files: ^(telegram|examples)/.*\.py$
args:
- --rcfile=setup.cfg
# 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
# https://pylint.pycqa.org/en/latest/user_guide/run.html?#parallel-execution to know more
- --jobs=0
additional_dependencies:
- httpx~=0.22.0
- tornado~=6.1
@@ -31,7 +36,7 @@ repos:
- cachetools~=5.0.0
- . # this basically does `pip install -e .`
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
rev: v0.950
hooks:
- id: mypy
name: mypy-ptb
@@ -58,9 +63,15 @@ repos:
- cachetools~=5.0.0
- . # this basically does `pip install -e .`
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
rev: v2.32.0
hooks:
- id: pyupgrade
files: ^(telegram|examples|tests)/.*\.py$
args:
- --py37-plus
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort
args: ["--diff"] # -diff will not apply the changes, just show them
+2 -2
View File
@@ -1,6 +1,6 @@
sphinx==4.4.0
sphinx==4.5.0
sphinx-pypi-upload
furo==2022.1.2
furo==2022.04.07
# Can be replaced with a sphinx-paramlinks==... dependency once a version is released that
# includes the commit mentioned below and maybe even
# https://github.com/sqlalchemyorg/sphinx-paramlinks/pull/14
+5 -5
View File
@@ -11,11 +11,11 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import subprocess
import re
import sys
import os
import inspect
import os
import re
import subprocess
import sys
from enum import Enum
from pathlib import Path
from typing import Tuple
@@ -34,7 +34,7 @@ sys.path.insert(0, os.path.abspath('../..'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '4.3.2'
needs_sphinx = '4.5.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+5 -6
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""This example showcases how PTBs "arbitrary callback data" feature can be used.
@@ -12,15 +12,14 @@ from typing import List, Tuple, cast
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import (
CommandHandler,
CallbackQueryHandler,
InvalidCallbackData,
PicklePersistence,
Application,
CallbackContext,
CallbackQueryHandler,
CommandHandler,
InvalidCallbackData,
PicklePersistence,
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
+14 -27
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -12,16 +12,11 @@ bot.
"""
import logging
from typing import Tuple, Optional
from typing import Optional, Tuple
from telegram import Update, Chat, ChatMember, ChatMemberUpdated
from telegram import Chat, ChatMember, ChatMemberUpdated, Update
from telegram.constants import ParseMode
from telegram.ext import (
CommandHandler,
ChatMemberHandler,
Application,
CallbackContext,
)
from telegram.ext import Application, CallbackContext, ChatMemberHandler, CommandHandler
# Enable logging
@@ -46,24 +41,16 @@ def extract_status_change(
return None
old_status, new_status = status_change
was_member = (
old_status
in [
ChatMember.MEMBER,
ChatMember.OWNER,
ChatMember.ADMINISTRATOR,
]
or (old_status == ChatMember.RESTRICTED and old_is_member is True)
)
is_member = (
new_status
in [
ChatMember.MEMBER,
ChatMember.OWNER,
ChatMember.ADMINISTRATOR,
]
or (new_status == ChatMember.RESTRICTED and new_is_member is True)
)
was_member = old_status in [
ChatMember.MEMBER,
ChatMember.OWNER,
ChatMember.ADMINISTRATOR,
] or (old_status == ChatMember.RESTRICTED and old_is_member is True)
is_member = new_status in [
ChatMember.MEMBER,
ChatMember.OWNER,
ChatMember.ADMINISTRATOR,
] or (new_status == ChatMember.RESTRICTED and new_is_member is True)
return was_member, is_member
+8 -8
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -14,16 +14,16 @@ import logging
from collections import defaultdict
from typing import DefaultDict, Optional, Set
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.constants import ParseMode
from telegram.ext import (
CommandHandler,
CallbackContext,
ContextTypes,
CallbackQueryHandler,
TypeHandler,
ExtBot,
Application,
CallbackContext,
CallbackQueryHandler,
CommandHandler,
ContextTypes,
ExtBot,
TypeHandler,
)
# Enable logging
+5 -6
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -18,15 +18,14 @@ import logging
from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove, Update
from telegram.ext import (
CommandHandler,
MessageHandler,
filters,
ConversationHandler,
Application,
CallbackContext,
CommandHandler,
ConversationHandler,
MessageHandler,
filters,
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
+6 -7
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -17,17 +17,16 @@ bot.
import logging
from typing import Dict
from telegram import ReplyKeyboardMarkup, Update, ReplyKeyboardRemove
from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove, Update
from telegram.ext import (
CommandHandler,
MessageHandler,
filters,
ConversationHandler,
Application,
CallbackContext,
CommandHandler,
ConversationHandler,
MessageHandler,
filters,
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
+5 -5
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""Bot that explains Telegram's "Deep Linking Parameters" functionality.
@@ -20,14 +20,14 @@ bot.
import logging
from telegram import InlineKeyboardMarkup, InlineKeyboardButton, Update, helpers
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, helpers
from telegram.constants import ParseMode
from telegram.ext import (
CommandHandler,
CallbackQueryHandler,
filters,
Application,
CallbackContext,
CallbackQueryHandler,
CommandHandler,
filters,
)
# Enable logging
+3 -10
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -17,15 +17,8 @@ bot.
import logging
from telegram import Update, ForceReply
from telegram.ext import (
CommandHandler,
MessageHandler,
filters,
Application,
CallbackContext,
)
from telegram import ForceReply, Update
from telegram.ext import Application, CallbackContext, CommandHandler, MessageHandler, filters
# Enable logging
logging.basicConfig(
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""This is a very simple example on how one could implement a custom error handler."""
@@ -10,7 +10,7 @@ import traceback
from telegram import Update
from telegram.constants import ParseMode
from telegram.ext import CommandHandler, Application, CallbackContext
from telegram.ext import Application, CallbackContext, CommandHandler
# Enable logging
logging.basicConfig(
+3 -3
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -13,12 +13,12 @@ Press Ctrl-C on the command line or send a signal to the process to stop the
bot.
"""
import logging
from uuid import uuid4
from html import escape
from uuid import uuid4
from telegram import InlineQueryResultArticle, InputTextMessageContent, Update
from telegram.constants import ParseMode
from telegram.ext import Application, InlineQueryHandler, CommandHandler, CallbackContext
from telegram.ext import Application, CallbackContext, CommandHandler, InlineQueryHandler
# Enable logging
logging.basicConfig(
+2 -8
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -9,13 +9,7 @@ Basic example for a bot that uses inline keyboards. For an in-depth explanation,
import logging
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import (
CommandHandler,
CallbackQueryHandler,
Application,
CallbackContext,
)
from telegram.ext import Application, CallbackContext, CallbackQueryHandler, CommandHandler
# Enable logging
logging.basicConfig(
+5 -5
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""Simple inline keyboard bot with multiple CallbackQueryHandlers.
@@ -15,16 +15,16 @@ Send /start to initiate the conversation.
Press Ctrl-C on the command line to stop the bot.
"""
import logging
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import (
CommandHandler,
CallbackQueryHandler,
ConversationHandler,
Application,
CallbackContext,
CallbackQueryHandler,
CommandHandler,
ConversationHandler,
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
+8 -9
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -15,20 +15,19 @@ bot.
"""
import logging
from typing import Tuple, Dict, Any
from typing import Any, Dict, Tuple
from telegram import InlineKeyboardMarkup, InlineKeyboardButton, Update
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import (
CommandHandler,
MessageHandler,
filters,
ConversationHandler,
CallbackQueryHandler,
Application,
CallbackContext,
CallbackQueryHandler,
CommandHandler,
ConversationHandler,
MessageHandler,
filters,
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -15,7 +15,7 @@ import logging
from pathlib import Path
from telegram import Update
from telegram.ext import MessageHandler, filters, Application, CallbackContext
from telegram.ext import Application, CallbackContext, MessageHandler, filters
# Enable logging
+6 -7
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""Basic example for a bot that can receive payment from user."""
@@ -8,16 +8,15 @@ import logging
from telegram import LabeledPrice, ShippingOption, Update
from telegram.ext import (
CommandHandler,
MessageHandler,
filters,
PreCheckoutQueryHandler,
ShippingQueryHandler,
Application,
CallbackContext,
CommandHandler,
MessageHandler,
PreCheckoutQueryHandler,
ShippingQueryHandler,
filters,
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
+7 -8
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -17,18 +17,17 @@ bot.
import logging
from typing import Dict
from telegram import ReplyKeyboardMarkup, Update, ReplyKeyboardRemove
from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove, Update
from telegram.ext import (
CommandHandler,
MessageHandler,
filters,
ConversationHandler,
PicklePersistence,
Application,
CallbackContext,
CommandHandler,
ConversationHandler,
MessageHandler,
PicklePersistence,
filters,
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
+7 -8
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -10,25 +10,24 @@ one the user sends the bot
import logging
from telegram import (
Poll,
KeyboardButton,
KeyboardButtonPollType,
Poll,
ReplyKeyboardMarkup,
ReplyKeyboardRemove,
Update,
)
from telegram.constants import ParseMode
from telegram.ext import (
CommandHandler,
PollAnswerHandler,
PollHandler,
MessageHandler,
filters,
Application,
CallbackContext,
CommandHandler,
MessageHandler,
PollAnswerHandler,
PollHandler,
filters,
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
+1 -3
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# pylint: disable=global-statement
"""Simple Bot to reply to Telegram messages.
This is built on the API wrapper, see echobot.py to see the same example built
@@ -11,8 +10,7 @@ import logging
from typing import NoReturn
from telegram import Bot
from telegram.error import NetworkError, Forbidden
from telegram.error import Forbidden, NetworkError
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=missing-function-docstring, unused-argument
# pylint: disable=unused-argument
# This program is dedicated to the public domain under the CC0 license.
"""
@@ -21,7 +21,7 @@ bot.
import logging
from telegram import Update
from telegram.ext import CommandHandler, Application, CallbackContext
from telegram.ext import Application, CallbackContext, CommandHandler
# Enable logging
logging.basicConfig(
+5 -1
View File
@@ -1,6 +1,6 @@
[tool.black]
line-length = 99
target-version = ['py37']
target-version = ['py37', 'py38', 'py39', 'py310']
skip-string-normalization = true
# We need to force-exclude the negated include pattern
@@ -8,3 +8,7 @@ skip-string-normalization = true
# see https://github.com/psf/black/issues/1778
force-exclude = '^(?!/(telegram|examples|tests)/).*\.py$'
include = '(telegram|examples|tests)/.*\.py$'
[tool.isort] # black config
profile = "black"
line_length = 99
+10 -11
View File
@@ -3,17 +3,16 @@ cryptography!=3.4,!=3.4.1,!=3.4.2,!=3.4.3
pre-commit
# Make sure that the versions specified here match the pre-commit settings!
black==21.9b0
# hardpinned dependency for black
click==8.0.2
black==22.3.0
flake8==4.0.1
pylint==2.12.1
mypy==0.910
pyupgrade==2.29.0
pylint==2.13.8
mypy==0.950
pyupgrade==2.32.0
isort==5.10.1
pytest==6.2.5
pytest-asyncio==0.16.0
pytest==7.1.2
pytest-asyncio==0.18.3
flaky
beautifulsoup4
wheel
flaky # Used for flaky tests (flaky decorator)
beautifulsoup4 # used in test_official for parsing tg docs
wheel # required for building the wheels for releases
+1
View File
@@ -2,6 +2,7 @@
"""The setup and build script for the python-telegram-bot-raw library."""
from setuptools import setup
from setup import get_setup_kwargs
setup(**get_setup_kwargs(raw=True))
+3 -1
View File
@@ -19,7 +19,8 @@ exclude = setup.py, setup-raw.py docs/source/conf.py
disable = duplicate-code,too-many-arguments,too-many-public-methods,too-few-public-methods,
broad-except,too-many-instance-attributes,fixme,missing-function-docstring,
missing-class-docstring,too-many-locals,too-many-lines,too-many-branches,
too-many-statements,cyclic-import
too-many-statements
enable=useless-suppression ; Warns about unused pylint ignores
[tool:pytest]
testpaths = tests
@@ -35,6 +36,7 @@ filterwarnings =
; and instead do a trick directly in tests/conftest.py
; ignore::telegram.utils.deprecate.TelegramDeprecationWarning
markers = dev: If you want to test a specific test, use this
asyncio_mode = auto
[coverage:run]
branch = True
+2 -2
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env python
"""The setup and build script for the python-telegram-bot library."""
import subprocess
from pathlib import Path
import sys
from pathlib import Path
from setuptools import setup, find_packages
from setuptools import find_packages, setup
def get_requirements(raw=False):
+93 -93
View File
@@ -172,79 +172,65 @@ __all__ = ( # Keep this alphabetically ordered
)
from ._telegramobject import TelegramObject
from ._bot import Bot
from ._botcommand import BotCommand
from ._webappdata import WebAppData
from ._webappinfo import WebAppInfo
from ._sentwebappmessage import SentWebAppMessage
from ._menubutton import MenuButton, MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp
from ._loginurl import LoginUrl
from ._games.callbackgame import CallbackGame
from ._user import User
from ._files.chatphoto import ChatPhoto
from ._botcommandscope import (
BotCommandScope,
BotCommandScopeAllChatAdministrators,
BotCommandScopeAllGroupChats,
BotCommandScopeAllPrivateChats,
BotCommandScopeChat,
BotCommandScopeChatAdministrators,
BotCommandScopeChatMember,
BotCommandScopeDefault,
)
from ._callbackquery import CallbackQuery
from ._chat import Chat
from ._chatadministratorrights import ChatAdministratorRights
from ._chatlocation import ChatLocation
from ._chatinvitelink import ChatInviteLink
from ._chatjoinrequest import ChatJoinRequest
from ._chatlocation import ChatLocation
from ._chatmember import (
ChatMember,
ChatMemberOwner,
ChatMemberAdministrator,
ChatMemberMember,
ChatMemberRestricted,
ChatMemberLeft,
ChatMemberBanned,
ChatMemberLeft,
ChatMemberMember,
ChatMemberOwner,
ChatMemberRestricted,
)
from ._chatmemberupdated import ChatMemberUpdated
from ._chatpermissions import ChatPermissions
from ._files.photosize import PhotoSize
from ._files.audio import Audio
from ._files.voice import Voice
from ._files.document import Document
from ._files.animation import Animation
from ._files.sticker import Sticker, StickerSet, MaskPosition
from ._files.video import Video
from ._files.contact import Contact
from ._files.location import Location
from ._files.venue import Venue
from ._files.videonote import VideoNote
from ._choseninlineresult import ChosenInlineResult
from ._dice import Dice
from ._userprofilephotos import UserProfilePhotos
from ._keyboardbuttonpolltype import KeyboardButtonPollType
from ._keyboardbutton import KeyboardButton
from ._replykeyboardmarkup import ReplyKeyboardMarkup
from ._replykeyboardremove import ReplyKeyboardRemove
from ._forcereply import ForceReply
from ._files.inputfile import InputFile
from ._files.animation import Animation
from ._files.audio import Audio
from ._files.chatphoto import ChatPhoto
from ._files.contact import Contact
from ._files.document import Document
from ._files.file import File
from ._messageentity import MessageEntity
from ._messageid import MessageId
from ._games.game import Game
from ._poll import Poll, PollOption, PollAnswer
from ._videochat import (
VideoChatStarted,
VideoChatEnded,
VideoChatParticipantsInvited,
VideoChatScheduled,
from ._files.inputfile import InputFile
from ._files.inputmedia import (
InputMedia,
InputMediaAnimation,
InputMediaAudio,
InputMediaDocument,
InputMediaPhoto,
InputMediaVideo,
)
from ._proximityalerttriggered import ProximityAlertTriggered
from ._payment.shippingaddress import ShippingAddress
from ._payment.orderinfo import OrderInfo
from ._payment.successfulpayment import SuccessfulPayment
from ._payment.invoice import Invoice
from ._passport.credentials import EncryptedCredentials
from ._passport.passportfile import PassportFile
from ._passport.data import IdDocumentData, PersonalDetails, ResidentialAddress
from ._passport.encryptedpassportelement import EncryptedPassportElement
from ._passport.passportdata import PassportData
from ._files.location import Location
from ._files.photosize import PhotoSize
from ._files.sticker import MaskPosition, Sticker, StickerSet
from ._files.venue import Venue
from ._files.video import Video
from ._files.videonote import VideoNote
from ._files.voice import Voice
from ._forcereply import ForceReply
from ._games.callbackgame import CallbackGame
from ._games.game import Game
from ._games.gamehighscore import GameHighScore
from ._inline.inlinekeyboardbutton import InlineKeyboardButton
from ._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from ._messageautodeletetimerchanged import MessageAutoDeleteTimerChanged
from ._message import Message
from ._callbackquery import CallbackQuery
from ._choseninlineresult import ChosenInlineResult
from ._inline.inputmessagecontent import InputMessageContent
from ._inline.inlinequery import InlineQuery
from ._inline.inlinequeryresult import InlineQueryResult
from ._inline.inlinequeryresultarticle import InlineQueryResultArticle
@@ -259,6 +245,7 @@ from ._inline.inlinequeryresultcachedvideo import InlineQueryResultCachedVideo
from ._inline.inlinequeryresultcachedvoice import InlineQueryResultCachedVoice
from ._inline.inlinequeryresultcontact import InlineQueryResultContact
from ._inline.inlinequeryresultdocument import InlineQueryResultDocument
from ._inline.inlinequeryresultgame import InlineQueryResultGame
from ._inline.inlinequeryresultgif import InlineQueryResultGif
from ._inline.inlinequeryresultlocation import InlineQueryResultLocation
from ._inline.inlinequeryresultmpeg4gif import InlineQueryResultMpeg4Gif
@@ -266,27 +253,31 @@ from ._inline.inlinequeryresultphoto import InlineQueryResultPhoto
from ._inline.inlinequeryresultvenue import InlineQueryResultVenue
from ._inline.inlinequeryresultvideo import InlineQueryResultVideo
from ._inline.inlinequeryresultvoice import InlineQueryResultVoice
from ._inline.inlinequeryresultgame import InlineQueryResultGame
from ._inline.inputtextmessagecontent import InputTextMessageContent
from ._inline.inputlocationmessagecontent import InputLocationMessageContent
from ._inline.inputvenuemessagecontent import InputVenueMessageContent
from ._payment.labeledprice import LabeledPrice
from ._inline.inputinvoicemessagecontent import InputInvoiceMessageContent
from ._inline.inputcontactmessagecontent import InputContactMessageContent
from ._payment.shippingoption import ShippingOption
from ._payment.precheckoutquery import PreCheckoutQuery
from ._payment.shippingquery import ShippingQuery
from ._webhookinfo import WebhookInfo
from ._games.gamehighscore import GameHighScore
from ._update import Update
from ._files.inputmedia import (
InputMedia,
InputMediaVideo,
InputMediaPhoto,
InputMediaAnimation,
InputMediaAudio,
InputMediaDocument,
from ._inline.inputinvoicemessagecontent import InputInvoiceMessageContent
from ._inline.inputlocationmessagecontent import InputLocationMessageContent
from ._inline.inputmessagecontent import InputMessageContent
from ._inline.inputtextmessagecontent import InputTextMessageContent
from ._inline.inputvenuemessagecontent import InputVenueMessageContent
from ._keyboardbutton import KeyboardButton
from ._keyboardbuttonpolltype import KeyboardButtonPollType
from ._loginurl import LoginUrl
from ._menubutton import MenuButton, MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp
from ._message import Message
from ._messageautodeletetimerchanged import MessageAutoDeleteTimerChanged
from ._messageentity import MessageEntity
from ._messageid import MessageId
from ._passport.credentials import (
Credentials,
DataCredentials,
EncryptedCredentials,
FileCredentials,
SecureData,
SecureValue,
)
from ._passport.data import IdDocumentData, PersonalDetails, ResidentialAddress
from ._passport.encryptedpassportelement import EncryptedPassportElement
from ._passport.passportdata import PassportData
from ._passport.passportelementerrors import (
PassportElementError,
PassportElementErrorDataField,
@@ -299,22 +290,31 @@ from ._passport.passportelementerrors import (
PassportElementErrorTranslationFiles,
PassportElementErrorUnspecified,
)
from ._passport.credentials import (
Credentials,
DataCredentials,
SecureData,
SecureValue,
FileCredentials,
)
from ._botcommandscope import (
BotCommandScope,
BotCommandScopeDefault,
BotCommandScopeAllPrivateChats,
BotCommandScopeAllGroupChats,
BotCommandScopeAllChatAdministrators,
BotCommandScopeChat,
BotCommandScopeChatAdministrators,
BotCommandScopeChatMember,
)
from ._bot import Bot
from ._passport.passportfile import PassportFile
from ._payment.invoice import Invoice
from ._payment.labeledprice import LabeledPrice
from ._payment.orderinfo import OrderInfo
from ._payment.precheckoutquery import PreCheckoutQuery
from ._payment.shippingaddress import ShippingAddress
from ._payment.shippingoption import ShippingOption
from ._payment.shippingquery import ShippingQuery
from ._payment.successfulpayment import SuccessfulPayment
from ._poll import Poll, PollAnswer, PollOption
from ._proximityalerttriggered import ProximityAlertTriggered
from ._replykeyboardmarkup import ReplyKeyboardMarkup
from ._replykeyboardremove import ReplyKeyboardRemove
from ._sentwebappmessage import SentWebAppMessage
from ._telegramobject import TelegramObject
from ._update import Update
from ._user import User
from ._userprofilephotos import UserProfilePhotos
from ._version import __version__, bot_api_version # noqa: F401
from ._videochat import (
VideoChatEnded,
VideoChatParticipantsInvited,
VideoChatScheduled,
VideoChatStarted,
)
from ._webappdata import WebAppData
from ._webappinfo import WebAppInfo
from ._webhookinfo import WebhookInfo
+52 -59
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# pylint: disable=no-name-in-module, no-self-argument, not-callable, no-member, too-many-arguments
# pylint: disable=too-many-public-methods
# pylint: disable=no-self-argument, not-callable, no-member, too-many-arguments
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
@@ -22,26 +21,25 @@
import asyncio
import functools
import logging
from contextlib import AbstractAsyncContextManager
import pickle
from contextlib import AbstractAsyncContextManager
from datetime import datetime
from types import TracebackType
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
List,
NoReturn,
Optional,
Sequence,
Tuple,
Type,
TypeVar,
Union,
no_type_check,
Dict,
cast,
Sequence,
Any,
NoReturn,
Type,
no_type_check,
)
try:
@@ -59,63 +57,59 @@ except ImportError:
serialization = None # type: ignore[assignment]
CRYPTO_INSTALLED = False
from telegram import (
Animation,
Audio,
BotCommand,
BotCommandScope,
Chat,
ChatMember,
ChatPermissions,
ChatPhoto,
Contact,
Document,
File,
GameHighScore,
InputMedia,
Location,
MaskPosition,
Message,
MessageId,
PassportElementError,
PhotoSize,
Poll,
ShippingOption,
Sticker,
StickerSet,
TelegramObject,
Update,
User,
UserProfilePhotos,
Venue,
Video,
VideoNote,
Voice,
WebhookInfo,
InlineKeyboardMarkup,
ChatInviteLink,
SentWebAppMessage,
ChatAdministratorRights,
MenuButton,
)
from telegram.error import InvalidToken, TelegramError
from telegram.constants import InlineQueryLimit
from telegram.request import BaseRequest, RequestData
from telegram.request._requestparameter import RequestParameter
from telegram.request._httpxrequest import HTTPXRequest
from telegram._botcommand import BotCommand
from telegram._botcommandscope import BotCommandScope
from telegram._chat import Chat
from telegram._chatadministratorrights import ChatAdministratorRights
from telegram._chatinvitelink import ChatInviteLink
from telegram._chatmember import ChatMember
from telegram._chatpermissions import ChatPermissions
from telegram._files.animation import Animation
from telegram._files.audio import Audio
from telegram._files.chatphoto import ChatPhoto
from telegram._files.contact import Contact
from telegram._files.document import Document
from telegram._files.file import File
from telegram._files.inputmedia import InputMedia
from telegram._files.location import Location
from telegram._files.photosize import PhotoSize
from telegram._files.sticker import MaskPosition, Sticker, StickerSet
from telegram._files.venue import Venue
from telegram._files.video import Video
from telegram._files.videonote import VideoNote
from telegram._files.voice import Voice
from telegram._games.gamehighscore import GameHighScore
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._menubutton import MenuButton
from telegram._message import Message
from telegram._messageid import MessageId
from telegram._passport.passportelementerrors import PassportElementError
from telegram._payment.shippingoption import ShippingOption
from telegram._poll import Poll
from telegram._sentwebappmessage import SentWebAppMessage
from telegram._telegramobject import TelegramObject
from telegram._update import Update
from telegram._user import User
from telegram._userprofilephotos import UserProfilePhotos
from telegram._utils.defaultvalue import DEFAULT_NONE, DefaultValue
from telegram._utils.files import is_local_file, parse_file_input
from telegram._utils.types import FileInput, JSONDict, ODVInput, DVInput, ReplyMarkup
from telegram._utils.types import DVInput, FileInput, JSONDict, ODVInput, ReplyMarkup
from telegram._webhookinfo import WebhookInfo
from telegram.constants import InlineQueryLimit
from telegram.error import InvalidToken, TelegramError
from telegram.request import BaseRequest, RequestData
from telegram.request._httpxrequest import HTTPXRequest
from telegram.request._requestparameter import RequestParameter
if TYPE_CHECKING:
from telegram import (
InlineQueryResult,
InputMediaAudio,
InputMediaDocument,
InputMediaPhoto,
InputMediaVideo,
LabeledPrice,
MessageEntity,
InlineQueryResult,
)
RT = TypeVar('RT')
@@ -552,7 +546,7 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
pool_timeout=pool_timeout,
api_kwargs=api_kwargs,
)
self._bot_user = User.de_json(result, self) # type: ignore[return-value, arg-type]
self._bot_user = User.de_json(result, self) # type: ignore[arg-type]
return self._bot_user # type: ignore[return-value]
@_log
@@ -2641,7 +2635,6 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
DEFAULT_NONE to NONE *before* calling to_dict() makes it way easier to drop None entries
from the json data.
"""
# pylint: disable=protected-access
if hasattr(res, 'parse_mode'):
res.parse_mode = DefaultValue.get_value(res.parse_mode)
if hasattr(res, 'input_message_content') and res.input_message_content:
@@ -2832,7 +2825,7 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
api_kwargs=api_kwargs,
)
return UserProfilePhotos.de_json(result, self) # type: ignore[return-value, arg-type]
return UserProfilePhotos.de_json(result, self) # type: ignore[arg-type]
@_log
async def get_file(
+1 -2
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# pylint: disable=too-few-public-methods
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
@@ -20,7 +19,7 @@
"""This module contains an object that represents a Telegram Bot Command."""
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class BotCommand(TelegramObject):
+3 -2
View File
@@ -18,9 +18,10 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=redefined-builtin
"""This module contains objects representing Telegram bot command scopes."""
from typing import Any, Union, Optional, TYPE_CHECKING, Dict, Type, ClassVar
from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Type, Union
from telegram import TelegramObject, constants
from telegram import constants
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
+8 -4
View File
@@ -18,20 +18,24 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=redefined-builtin
"""This module contains an object that represents a Telegram CallbackQuery"""
from typing import TYPE_CHECKING, Any, List, Optional, Union, Tuple, ClassVar
from typing import TYPE_CHECKING, Any, ClassVar, List, Optional, Tuple, Union
from telegram import Message, TelegramObject, User, Location, constants
from telegram import constants
from telegram._files.location import Location
from telegram._message import Message
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import JSONDict, ODVInput, DVInput, ReplyMarkup
from telegram._utils.types import DVInput, JSONDict, ODVInput, ReplyMarkup
if TYPE_CHECKING:
from telegram import (
Bot,
GameHighScore,
InlineKeyboardMarkup,
MessageId,
InputMedia,
MessageEntity,
MessageId,
)
+19 -17
View File
@@ -19,38 +19,40 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Chat."""
from datetime import datetime
from typing import TYPE_CHECKING, List, Optional, ClassVar, Union, Tuple, Any
from typing import TYPE_CHECKING, Any, ClassVar, List, Optional, Tuple, Union
from telegram import ChatPhoto, TelegramObject, constants, MenuButton
from telegram._utils import enum
from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput, ReplyMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._chatpermissions import ChatPermissions
from telegram import constants
from telegram._chatlocation import ChatLocation
from telegram._chatpermissions import ChatPermissions
from telegram._files.chatphoto import ChatPhoto
from telegram._menubutton import MenuButton
from telegram._telegramobject import TelegramObject
from telegram._utils import enum
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import DVInput, FileInput, JSONDict, ODVInput, ReplyMarkup
if TYPE_CHECKING:
from telegram import (
Animation,
Audio,
Bot,
ChatMember,
ChatInviteLink,
Message,
MessageId,
ChatMember,
Contact,
Document,
InlineKeyboardMarkup,
Location,
Venue,
MessageEntity,
InputMediaAudio,
InputMediaDocument,
InputMediaPhoto,
InputMediaVideo,
PhotoSize,
Audio,
Document,
Animation,
LabeledPrice,
Location,
Message,
MessageEntity,
MessageId,
PhotoSize,
Sticker,
Venue,
Video,
VideoNote,
Voice,
+1 -1
View File
@@ -20,7 +20,7 @@
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class ChatAdministratorRights(TelegramObject):
+2 -1
View File
@@ -20,7 +20,8 @@
import datetime
from typing import TYPE_CHECKING, Any, Optional
from telegram import TelegramObject, User
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils.datetime import from_timestamp, to_timestamp
from telegram._utils.types import JSONDict
+4 -1
View File
@@ -20,7 +20,10 @@
import datetime
from typing import TYPE_CHECKING, Any, Optional
from telegram import TelegramObject, User, Chat, ChatInviteLink
from telegram._chat import Chat
from telegram._chatinvitelink import ChatInviteLink
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils.datetime import from_timestamp, to_timestamp
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import JSONDict, ODVInput
+2 -3
View File
@@ -20,10 +20,9 @@
from typing import TYPE_CHECKING, Any, Optional
from telegram import TelegramObject
from telegram._utils.types import JSONDict
from telegram._files.location import Location
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
from telegram import Bot
+4 -2
View File
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ChatMember."""
import datetime
from typing import TYPE_CHECKING, Optional, ClassVar, Dict, Type
from typing import TYPE_CHECKING, ClassVar, Dict, Optional, Type
from telegram import TelegramObject, User, constants
from telegram import constants
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils.datetime import from_timestamp, to_timestamp
from telegram._utils.types import JSONDict
+6 -2
View File
@@ -18,9 +18,13 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ChatMemberUpdated."""
import datetime
from typing import TYPE_CHECKING, Any, Optional, Dict, Tuple, Union
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union
from telegram import TelegramObject, User, Chat, ChatMember, ChatInviteLink
from telegram._chat import Chat
from telegram._chatinvitelink import ChatInviteLink
from telegram._chatmember import ChatMember
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils.datetime import from_timestamp, to_timestamp
from telegram._utils.types import JSONDict
+1 -1
View File
@@ -20,7 +20,7 @@
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class ChatPermissions(TelegramObject):
+4 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=too-many-instance-attributes, too-many-arguments
# pylint: disable=too-many-arguments
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
@@ -21,7 +21,9 @@
from typing import TYPE_CHECKING, Any, Optional
from telegram import Location, TelegramObject, User
from telegram._files.location import Location
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
+3 -3
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# pylint: disable=too-few-public-methods
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
@@ -18,9 +17,10 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Dice."""
from typing import Any, List, ClassVar
from typing import Any, ClassVar, List
from telegram import TelegramObject, constants
from telegram import constants
from telegram._telegramobject import TelegramObject
class Dice(TelegramObject):
+1 -1
View File
@@ -19,7 +19,7 @@
"""Common base class for media objects"""
from typing import TYPE_CHECKING
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import JSONDict, ODVInput
+7 -4
View File
@@ -17,16 +17,17 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""Common base class for media objects with thumbnails"""
from typing import TYPE_CHECKING, TypeVar, Type, Optional
from typing import TYPE_CHECKING, Optional, Type, TypeVar
from telegram import PhotoSize
from telegram._files._basemedium import _BaseMedium
from telegram._files.photosize import PhotoSize
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
from telegram import Bot
ThumbedMT = TypeVar('ThumbedMT', bound='_BaseThumbedMedium', covariant=True)
# pylint: disable=invalid-name
ThumbedMT_co = TypeVar('ThumbedMT_co', bound='_BaseThumbedMedium', covariant=True)
class _BaseThumbedMedium(_BaseMedium):
@@ -73,7 +74,9 @@ class _BaseThumbedMedium(_BaseMedium):
self.thumb = thumb
@classmethod
def de_json(cls: Type[ThumbedMT], data: Optional[JSONDict], bot: 'Bot') -> Optional[ThumbedMT]:
def de_json(
cls: Type[ThumbedMT_co], data: Optional[JSONDict], bot: 'Bot'
) -> Optional[ThumbedMT_co]:
"""See :meth:`telegram.TelegramObject.de_json`."""
data = cls._parse_data(data)
+1 -1
View File
@@ -19,8 +19,8 @@
"""This module contains an object that represents a Telegram Animation."""
from typing import TYPE_CHECKING, Any
from telegram import PhotoSize
from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize
if TYPE_CHECKING:
from telegram import Bot
+1 -1
View File
@@ -20,8 +20,8 @@
from typing import TYPE_CHECKING, Any
from telegram import PhotoSize
from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize
if TYPE_CHECKING:
from telegram import Bot
+1 -1
View File
@@ -19,7 +19,7 @@
"""This module contains an object that represents a Telegram ChatPhoto."""
from typing import TYPE_CHECKING, Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import JSONDict, ODVInput
+1 -1
View File
@@ -20,7 +20,7 @@
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class Contact(TelegramObject):
+1 -1
View File
@@ -20,8 +20,8 @@
from typing import TYPE_CHECKING, Any
from telegram import PhotoSize
from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize
if TYPE_CHECKING:
from telegram import Bot
+1 -1
View File
@@ -23,8 +23,8 @@ from base64 import b64decode
from pathlib import Path
from typing import IO, TYPE_CHECKING, Any, Optional, Union
from telegram import TelegramObject
from telegram._passport.credentials import decrypt
from telegram._telegramobject import TelegramObject
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.files import is_local_file
from telegram._utils.types import FilePathInput, ODVInput
-1
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# pylint: disable=redefined-builtin, no-name-in-module
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
+10 -14
View File
@@ -17,18 +17,16 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""Base class for Telegram InputMedia Objects."""
from typing import Union, List, Tuple, Optional
from typing import List, Optional, Tuple, Union
from telegram import (
Animation,
Audio,
Document,
InputFile,
PhotoSize,
TelegramObject,
Video,
MessageEntity,
)
from telegram._files.animation import Animation
from telegram._files.audio import Audio
from telegram._files.document import Document
from telegram._files.inputfile import InputFile
from telegram._files.photosize import PhotoSize
from telegram._files.video import Video
from telegram._messageentity import MessageEntity
from telegram._telegramobject import TelegramObject
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.files import parse_file_input
from telegram._utils.types import FileInput, JSONDict, ODVInput
@@ -95,9 +93,7 @@ class InputMedia(TelegramObject):
data = super().to_dict()
if self.caption_entities:
data['caption_entities'] = [
ce.to_dict() for ce in self.caption_entities # pylint: disable=not-an-iterable
]
data['caption_entities'] = [ce.to_dict() for ce in self.caption_entities]
return data
+1 -1
View File
@@ -20,7 +20,7 @@
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class Location(TelegramObject):
+4 -2
View File
@@ -18,10 +18,12 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains objects that represent stickers."""
from typing import TYPE_CHECKING, Any, List, Optional, ClassVar
from typing import TYPE_CHECKING, Any, ClassVar, List, Optional
from telegram import PhotoSize, TelegramObject, constants
from telegram import constants
from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
+2 -1
View File
@@ -20,7 +20,8 @@
from typing import TYPE_CHECKING, Any, Optional
from telegram import Location, TelegramObject
from telegram._files.location import Location
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
+1 -1
View File
@@ -20,8 +20,8 @@
from typing import TYPE_CHECKING, Any
from telegram import PhotoSize
from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize
if TYPE_CHECKING:
from telegram import Bot
+1 -1
View File
@@ -20,8 +20,8 @@
from typing import TYPE_CHECKING, Any
from telegram import PhotoSize
from telegram._files._basethumbedmedium import _BaseThumbedMedium
from telegram._files.photosize import PhotoSize
if TYPE_CHECKING:
from telegram import Bot
+1 -1
View File
@@ -20,7 +20,7 @@
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class ForceReply(TelegramObject):
+1 -1
View File
@@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram CallbackGame."""
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class CallbackGame(TelegramObject):
+4 -1
View File
@@ -21,7 +21,10 @@
import sys
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from telegram import Animation, MessageEntity, PhotoSize, TelegramObject
from telegram._files.animation import Animation
from telegram._files.photosize import PhotoSize
from telegram._messageentity import MessageEntity
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
+2 -1
View File
@@ -20,7 +20,8 @@
from typing import TYPE_CHECKING, Optional
from telegram import TelegramObject, User
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
+4 -1
View File
@@ -20,8 +20,11 @@
from typing import TYPE_CHECKING, Any, Optional
from telegram import TelegramObject, LoginUrl, WebAppInfo, CallbackGame
from telegram._games.callbackgame import CallbackGame
from telegram._loginurl import LoginUrl
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
from telegram._webappinfo import WebAppInfo
if TYPE_CHECKING:
from telegram import Bot
+3 -2
View File
@@ -20,9 +20,10 @@
from typing import TYPE_CHECKING, Any, List, Optional
from telegram import InlineKeyboardButton, TelegramObject
from telegram._utils.types import JSONDict
from telegram._inline.inlinekeyboardbutton import InlineKeyboardButton
from telegram._telegramobject import TelegramObject
from telegram._utils.markup import check_keyboard_type
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
from telegram import Bot
+6 -3
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# pylint: disable=too-many-instance-attributes, too-many-arguments
# pylint: disable=too-many-arguments
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
@@ -19,9 +19,12 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram InlineQuery."""
from typing import TYPE_CHECKING, Any, Optional, Union, Callable, ClassVar, Sequence
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Optional, Sequence, Union
from telegram import Location, TelegramObject, User, constants
from telegram import constants
from telegram._files.location import Location
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import JSONDict, ODVInput
+1 -1
View File
@@ -21,7 +21,7 @@
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
+2 -1
View File
@@ -20,7 +20,8 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
+4 -2
View File
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultAudio."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedAudio."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
@@ -16,12 +16,13 @@
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=redefined-builtin
"""This module contains the classes that represent Telegram InlineQueryResultCachedDocument."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedGif."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultMpeg4Gif."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
@@ -16,12 +16,13 @@
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=redefined-builtin
"""This module contains the classes that represent Telegram InlineQueryResultPhoto"""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
@@ -20,7 +20,8 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedVideo."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultCachedVoice."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
+2 -1
View File
@@ -20,7 +20,8 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultDocument"""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
+3 -2
View File
@@ -20,7 +20,8 @@
from typing import Any
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram.constants import InlineQueryResultType
@@ -54,7 +55,7 @@ class InlineQueryResultGame(InlineQueryResult):
):
# Required
super().__init__(InlineQueryResultType.GAME, id)
self.id = id # pylint: disable=redefined-builtin
self.id = id
self.game_short_name = game_short_name
self.reply_markup = reply_markup
+4 -3
View File
@@ -16,12 +16,13 @@
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=redefined-builtin
"""This module contains the classes that represent Telegram InlineQueryResultGif."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
@@ -20,7 +20,8 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultMpeg4Gif."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
+4 -2
View File
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultPhoto."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
+2 -1
View File
@@ -20,7 +20,8 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
+4 -2
View File
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultVideo."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
+4 -2
View File
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultVoice."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from typing import TYPE_CHECKING, Any, List, Tuple, Union
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._inline.inlinequeryresult import InlineQueryResult
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
@@ -20,7 +20,7 @@
from typing import Any
from telegram import InputMessageContent
from telegram._inline.inputmessagecontent import InputMessageContent
class InputContactMessageContent(InputMessageContent):
@@ -18,9 +18,10 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains a class that represents a Telegram InputInvoiceMessageContent."""
from typing import Any, List, Optional, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, List, Optional
from telegram import InputMessageContent, LabeledPrice
from telegram._inline.inputmessagecontent import InputMessageContent
from telegram._payment.labeledprice import LabeledPrice
from telegram._utils.types import JSONDict
if TYPE_CHECKING:
@@ -20,7 +20,7 @@
from typing import Any
from telegram import InputMessageContent
from telegram._inline.inputmessagecontent import InputMessageContent
class InputLocationMessageContent(InputMessageContent):
+1 -1
View File
@@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InputMessageContent."""
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class InputMessageContent(TelegramObject):
+3 -2
View File
@@ -18,9 +18,10 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InputTextMessageContent."""
from typing import Any, Union, Tuple, List
from typing import Any, List, Tuple, Union
from telegram import InputMessageContent, MessageEntity
from telegram._inline.inputmessagecontent import InputMessageContent
from telegram._messageentity import MessageEntity
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import JSONDict, ODVInput
+1 -1
View File
@@ -20,7 +20,7 @@
from typing import Any
from telegram import InputMessageContent
from telegram._inline.inputmessagecontent import InputMessageContent
class InputVenueMessageContent(InputMessageContent):
+3 -1
View File
@@ -20,8 +20,10 @@
from typing import TYPE_CHECKING, Any, Optional
from telegram import TelegramObject, KeyboardButtonPollType, WebAppInfo
from telegram._keyboardbuttonpolltype import KeyboardButtonPollType
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
from telegram._webappinfo import WebAppInfo
if TYPE_CHECKING:
from telegram import Bot
+1 -2
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# pylint: disable=too-few-public-methods
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
@@ -20,7 +19,7 @@
"""This module contains an object that represents a type of a Telegram Poll."""
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class KeyboardButtonPollType(TelegramObject):
+1 -2
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# pylint: disable=too-few-public-methods
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
@@ -20,7 +19,7 @@
"""This module contains an object that represents a Telegram LoginUrl."""
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class LoginUrl(TelegramObject):
+4 -3
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# pylint: disable=too-few-public-methods
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
@@ -18,10 +17,12 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains objects related to Telegram menu buttons."""
from typing import Any, ClassVar, Optional, TYPE_CHECKING, Dict, Type
from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Type
from telegram import TelegramObject, constants, WebAppInfo
from telegram import constants
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
from telegram._webappinfo import WebAppInfo
if TYPE_CHECKING:
from telegram import Bot
+37 -39
View File
@@ -21,56 +21,56 @@
import datetime
import sys
from html import escape
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, Tuple
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from telegram import (
Animation,
Audio,
Chat,
Contact,
Dice,
Document,
Game,
InlineKeyboardMarkup,
Invoice,
Location,
MessageEntity,
PassportData,
PhotoSize,
Poll,
Sticker,
SuccessfulPayment,
TelegramObject,
User,
Venue,
Video,
VideoNote,
Voice,
VideoChatStarted,
VideoChatEnded,
VideoChatParticipantsInvited,
ProximityAlertTriggered,
MessageAutoDeleteTimerChanged,
VideoChatScheduled,
WebAppData,
)
from telegram.constants import ParseMode, MessageAttachmentType
from telegram.helpers import escape_markdown
from telegram._chat import Chat
from telegram._dice import Dice
from telegram._files.animation import Animation
from telegram._files.audio import Audio
from telegram._files.contact import Contact
from telegram._files.document import Document
from telegram._files.location import Location
from telegram._files.photosize import PhotoSize
from telegram._files.sticker import Sticker
from telegram._files.venue import Venue
from telegram._files.video import Video
from telegram._files.videonote import VideoNote
from telegram._files.voice import Voice
from telegram._games.game import Game
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
from telegram._messageautodeletetimerchanged import MessageAutoDeleteTimerChanged
from telegram._messageentity import MessageEntity
from telegram._passport.passportdata import PassportData
from telegram._payment.invoice import Invoice
from telegram._payment.successfulpayment import SuccessfulPayment
from telegram._poll import Poll
from telegram._proximityalerttriggered import ProximityAlertTriggered
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils.datetime import from_timestamp, to_timestamp
from telegram._utils.defaultvalue import DEFAULT_NONE, DefaultValue
from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput, ReplyMarkup
from telegram._utils.types import DVInput, FileInput, JSONDict, ODVInput, ReplyMarkup
from telegram._videochat import (
VideoChatEnded,
VideoChatParticipantsInvited,
VideoChatScheduled,
VideoChatStarted,
)
from telegram._webappdata import WebAppData
from telegram.constants import MessageAttachmentType, ParseMode
from telegram.helpers import escape_markdown
if TYPE_CHECKING:
from telegram import (
Bot,
GameHighScore,
InputMedia,
MessageId,
InputMediaAudio,
InputMediaDocument,
InputMediaPhoto,
InputMediaVideo,
LabeledPrice,
MessageId,
)
@@ -738,9 +738,7 @@ class Message(TelegramObject):
# Unfortunately we need some ExtBot logic here because it's hard to move shortcut
# logic into ExtBot
if hasattr(self.get_bot(), 'defaults') and self.get_bot().defaults: # type: ignore
default_quote = (
self.get_bot().defaults.quote # type: ignore[union-attr, attr-defined]
)
default_quote = self.get_bot().defaults.quote # type: ignore[attr-defined]
else:
default_quote = None
if (default_quote is None and self.chat.type != Chat.PRIVATE) or default_quote:
+1 -1
View File
@@ -22,7 +22,7 @@ deletion.
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class MessageAutoDeleteTimerChanged(TelegramObject):
+4 -2
View File
@@ -18,9 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram MessageEntity."""
from typing import TYPE_CHECKING, Any, List, Optional, ClassVar
from typing import TYPE_CHECKING, Any, ClassVar, List, Optional
from telegram import TelegramObject, User, constants
from telegram import constants
from telegram._telegramobject import TelegramObject
from telegram._user import User
from telegram._utils import enum
from telegram._utils.types import JSONDict
+1 -1
View File
@@ -19,7 +19,7 @@
"""This module contains an object that represents an instance of a Telegram MessageId."""
from typing import Any
from telegram import TelegramObject
from telegram._telegramobject import TelegramObject
class MessageId(TelegramObject):

Some files were not shown because too many files have changed in this diff Show More