Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Prepare for Py +3.9 support#4398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Bibo-Joshi merged 13 commits intopython-telegram-bot:masterfromelpekenin:39-changes
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion.github/workflows/unit_tests.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ jobs:
runs-on: ${{matrix.os}}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: False
steps:
Expand Down
2 changes: 1 addition & 1 deletion.pre-commit-config.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,7 +72,7 @@ repos:
hooks:
- id: pyupgrade
args:
- --py38-plus
- --py39-plus
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
Expand Down
2 changes: 1 addition & 1 deletionREADME.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ Introduction

This library provides a pure Python, asynchronous interface for the
`Telegram Bot API <https://core.telegram.org/bots/api>`_.
It's compatible with Python versions **3.8+**.
It's compatible with Python versions **3.9+**.

In addition to the pure API implementation, this library features several convenience methods and shortcuts as well as a number of high-level classes to
make the development of bots easy and straightforward. These classes are contained in the
Expand Down
3 changes: 2 additions & 1 deletiondocs/auxil/admonition_inserter.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,8 @@
import re
import typing
from collections import defaultdict
from typing import Any, Iterator, Union
from collections.abc import Iterator
from typing import Any, Union

import telegram
import telegram.ext
Expand Down
3 changes: 1 addition & 2 deletionsdocs/auxil/kwargs_insertion.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,6 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import inspect
from typing import List

keyword_args = [
"Keyword Arguments:",
Expand DownExpand Up@@ -85,7 +84,7 @@
]


def find_insert_pos_for_kwargs(lines:List[str]) -> int:
def find_insert_pos_for_kwargs(lines:list[str]) -> int:
"""Finds the correct position to insert the keyword arguments and returns the index."""
for idx, value in reversed(list(enumerate(lines))): # reversed since :returns: is at the end
if value.startswith("Returns"):
Expand Down
3 changes: 1 addition & 2 deletionsdocs/auxil/link_code.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,6 @@
"""
import subprocess
from pathlib import Path
from typing import Dict, Tuple

from sphinx.util import logging

Expand All@@ -32,7 +31,7 @@

# must be a module-level variable so that it can be written to by the `autodoc-process-docstring`
# event handler in `sphinx_hooks.py`
LINE_NUMBERS:Dict[str,Tuple[Path, int, int]] = {}
LINE_NUMBERS:dict[str,tuple[Path, int, int]] = {}


def _git_branch() -> str:
Expand Down
8 changes: 4 additions & 4 deletionsexamples/arbitrarycallbackdatabot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@
`pip install "python-telegram-bot[callback-data]"`
"""
import logging
from typing importList, Tuple,cast
from typing import cast

from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import (
Expand All@@ -36,7 +36,7 @@

async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""Sends a message with 5 inline buttons attached."""
number_list:List[int] = []
number_list:list[int] = []
await update.message.reply_text("Please choose:", reply_markup=build_keyboard(number_list))


Expand All@@ -55,7 +55,7 @@ async def clear(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.effective_message.reply_text("All clear!")


def build_keyboard(current_list:List[int]) -> InlineKeyboardMarkup:
def build_keyboard(current_list:list[int]) -> InlineKeyboardMarkup:
"""Helper function to build the next inline keyboard."""
return InlineKeyboardMarkup.from_column(
[InlineKeyboardButton(str(i), callback_data=(i, current_list)) for i in range(1, 6)]
Expand All@@ -69,7 +69,7 @@ async def list_button(update: Update, context: ContextTypes.DEFAULT_TYPE) -> Non
# Get the data from the callback_data.
# If you're using a type checker like MyPy, you'll have to use typing.cast
# to make the checker get the expected type of the callback_data
number, number_list = cast(Tuple[int,List[int]], query.data)
number, number_list = cast(tuple[int,list[int]], query.data)
# append the number to the list
number_list.append(number)

Expand Down
4 changes: 2 additions & 2 deletionsexamples/chatmemberbot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@
"""

import logging
from typing import Optional, Tuple
from typing import Optional

from telegram import Chat, ChatMember, ChatMemberUpdated, Update
from telegram.constants import ParseMode
Expand All@@ -37,7 +37,7 @@
logger = logging.getLogger(__name__)


def extract_status_change(chat_member_update: ChatMemberUpdated) -> Optional[Tuple[bool, bool]]:
def extract_status_change(chat_member_update: ChatMemberUpdated) -> Optional[tuple[bool, bool]]:
"""Takes a ChatMemberUpdated instance and extracts whether the 'old_chat_member' was a member
of the chat and whether the 'new_chat_member' is a member of the chat. Returns None, if
the status didn't change.
Expand Down
6 changes: 3 additions & 3 deletionsexamples/contexttypesbot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@

import logging
from collections import defaultdict
from typing importDefaultDict,Optional, Set
from typing import Optional

from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.constants import ParseMode
Expand DownExpand Up@@ -40,7 +40,7 @@ class ChatData:
"""Custom class for chat_data. Here we store data per message."""

def __init__(self) -> None:
self.clicks_per_message:DefaultDict[int, int] = defaultdict(int)
self.clicks_per_message:defaultdict[int, int] = defaultdict(int)


# The [ExtBot, dict, ChatData, dict] is for type checkers like mypy
Expand All@@ -57,7 +57,7 @@ def __init__(
self._message_id: Optional[int] = None

@property
def bot_user_ids(self) ->Set[int]:
def bot_user_ids(self) ->set[int]:
"""Custom shortcut to access a value stored in the bot_data dict"""
return self.bot_data.setdefault("user_ids", set())

Expand Down
3 changes: 1 addition & 2 deletionsexamples/conversationbot2.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,6 @@
"""

import logging
from typing import Dict

from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove, Update
from telegram.ext import (
Expand DownExpand Up@@ -46,7 +45,7 @@
markup = ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True)


def facts_to_str(user_data:Dict[str, str]) -> str:
def facts_to_str(user_data:dict[str, str]) -> str:
"""Helper function for formatting the gathered user info."""
facts = [f"{key} - {value}" for key, value in user_data.items()]
return "\n".join(facts).join(["\n", "\n"])
Expand Down
6 changes: 3 additions & 3 deletionsexamples/nestedconversationbot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"""

import logging
from typing import Any, Dict, Tuple
from typing import Any

from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import (
Expand DownExpand Up@@ -66,7 +66,7 @@


# Helper
def _name_switcher(level: str) ->Tuple[str, str]:
def _name_switcher(level: str) ->tuple[str, str]:
if level == PARENTS:
return "Father", "Mother"
return "Brother", "Sister"
Expand DownExpand Up@@ -122,7 +122,7 @@ async def adding_self(update: Update, context: ContextTypes.DEFAULT_TYPE) -> str
async def show_data(update: Update, context: ContextTypes.DEFAULT_TYPE) -> str:
"""Pretty print gathered data."""

def pretty_print(data:Dict[str, Any], level: str) -> str:
def pretty_print(data:dict[str, Any], level: str) -> str:
people = data.get(level)
if not people:
return "\nNo information yet."
Expand Down
3 changes: 1 addition & 2 deletionsexamples/persistentconversationbot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,6 @@
"""

import logging
from typing import Dict

from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove, Update
from telegram.ext import (
Expand DownExpand Up@@ -47,7 +46,7 @@
markup = ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True)


def facts_to_str(user_data:Dict[str, str]) -> str:
def facts_to_str(user_data:dict[str, str]) -> str:
"""Helper function for formatting the gathered user info."""
facts = [f"{key} - {value}" for key, value in user_data.items()]
return "\n".join(facts).join(["\n", "\n"])
Expand Down
5 changes: 2 additions & 3 deletionspyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ dynamic = ["version"]
name = "python-telegram-bot"
description = "We have made you a wrapper you can't refuse"
readme = "README.rst"
requires-python = ">=3.8"
requires-python = ">=3.9"
license = "LGPL-3.0-only"
license-files = { paths = ["LICENSE", "LICENSE.dual", "LICENSE.lesser"] }
authors = [
Expand All@@ -31,7 +31,6 @@ classifiers = [
"Topic :: Internet",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand DownExpand Up@@ -192,7 +191,7 @@ disallow_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_decorators = true
show_error_codes = true
python_version = "3.8"
python_version = "3.9"

# For some files, it's easier to just disable strict-optional all together instead of
# cluttering the code with `# type: ignore`s or stuff like
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp