10000 Recover 100% Type Completeness (#3676) · Devors/python-telegram-bot@66b6d3c · GitHub
[go: up one dir, main page]

Skip to content

Commit 66b6d3c

Browse files
authored
Recover 100% Type Completeness (python-telegram-bot#3676)
1 parent 8c252c9 commit 66b6d3c

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

.github/workflows/type_completeness.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ jobs:
4949
pr = float(
5050
json.load(open("pr.json", "rb"))["typeCompleteness"]["completenessScore"]
5151
)
52-
base_text = f"After this PR, type completeness will be {round(pr, 3)}."
53-
if pr < (base - 0.1):
54-
text = f"This PR decreases type completeness by {round(base - pr, 3)}. ❌"
52+
base_text = f"This PR changes type completeness from {round(base, 3)} to {round(pr, 3)}."
53+
if pr < (base - 0.001):
54+
text = f"{base_text} ❌"
5555
set_summary(text)
5656
print(Path("pr.readable").read_text(encoding="utf-8"))
57-
error(f"{text}\n{base_text}")
57+
error(text)
5858
exit(1)
59-
elif pr > (base + 0.1):
60-
text = f"This PR increases type completeness by {round(pr - base, 3)}. ✨"
59+
elif pr > (base + 0.001):
60+
text = f"{base_text} ✨"
6161
set_summary(text)
6262
if pr < 1:
6363
print(Path("pr.readable").read_text(encoding="utf-8"))
64-
print(f"{text}\n{base_text}")
64+
print(text)
6565
else:
66-
text = f"This PR does not change type completeness by more than 0.1. ✅"
66+
text = f"{base_text} This is less than 0.1 percentage points. ✅"
6767
set_summary(text)
6868
print(Path("pr.readable").read_text(encoding="utf-8"))
69-
print(f"{text}\n{base_text}")
69+
print(text)

telegram/_bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def __init__(
244244
self._local_mode: bool = local_mode
245245
self._bot_user: Optional[User] = None
246246
self._private_key: Optional[bytes] = None
247-
self._initialized = False
247+
self._initialized: bool = False
248248

249249
self._request: Tuple[BaseRequest, BaseRequest] = (
250250
HTTPXRequest() if get_updates_request is None else get_updates_request,
@@ -375,7 +375,7 @@ def __deepcopy__(self, memodict: Dict[int, object]) -> NoReturn:
375375
# consider adding Paramspec from typing_extensions to properly fix this. Currently a workaround
376376
def _log(func: Any): # type: ignore[no-untyped-def] # skipcq: PY-D0003
377377
@functools.wraps(func)
378-
async def decorator(self, *args, **kwargs): # type: ignore[no-untyped-def]
378+
async def decorator(self: "Bot", *args: Any, **kwargs: Any) -> Any:
379379
# pylint: disable=protected-access
380380
self._LOGGER.debug("Entering: %s", func.__name__)
381381
result = await func(self, *args, **kwargs) # skipcq: PYL-E1102

telegram/_botdescription.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class BotDescription(TelegramObject):
4141

4242
def __init__(self, description: str, *, api_kwargs: JSONDict = None):
4343
super().__init__(api_kwargs=api_kwargs)
44-
self.description = description
44+
self.description: str = description
4545

4646
self._id_attrs = (self.description,)
4747

@@ -68,7 +68,7 @@ class BotShortDescription(TelegramObject):
6868

6969
def __init__(self, short_description: str, *, api_kwargs: JSONDict = None):
7070
super().__init__(api_kwargs=api_kwargs)
71-
self.short_description = short_description
71+
self.short_description: str = short_description
7272

7373
self._id_attrs = (self.short_description,)
7474

telegram/_botname.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class BotName(TelegramObject):
4444

4545
def __init__(self, name: str, *, api_kwargs: JSONDict = None):
4646
super().__init__(api_kwargs=api_kwargs)
47-
self.name = name
47+
self.name: str = name
4848

4949
self._id_attrs = (self.name,)
5050

telegram/_switchinlinequerychosenchat.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717
# You should have received a copy of the GNU Lesser Public License
1818
"""This module contains a class that represents a Telegram SwitchInlineQueryChosenChat."""
19+
from typing import Optional
1920

2021
from telegram._telegramobject import TelegramObject
2122
from telegram._utils.types import JSONDict
@@ -82,11 +83,11 @@ def __init__(
8283
):
8384
super().__init__(api_kwargs=api_kwargs)
8485
# Optional
85-
self.query = query
86-
self.allow_user_chats = allow_user_chats
87-
self.allow_bot_chats = allow_bot_chats
88-
self.allow_group_chats = allow_group_chats
89-
self.allow_channel_chats = allow_channel_chats
86+
self.query: Optional[str] = query
87+
self.allow_user_chats: Optional[bool] = allow_user_chats
88+
self.allow_bot_chats: Optional[bool] = allow_bot_chats
89+
self.allow_group_chats: Optional[bool] = allow_group_chats
90+
self.allow_channel_chats: Optional[bool] = allow_channel_chats
9091

9192
self._id_attrs = (
9293
self.query,

0 commit comments

Comments
 (0)
0