Recover 100% Type Completeness (#3676)

This commit is contained in:
Bibo-Joshi 2023-05-07 14:10:20 +02:00 committed by GitHub
parent 8c252c9822
commit 66b6d3c497
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 19 deletions

View file

@ -49,21 +49,21 @@ jobs:
pr = float(
json.load(open("pr.json", "rb"))["typeCompleteness"]["completenessScore"]
)
base_text = f"After this PR, type completeness will be {round(pr, 3)}."
if pr < (base - 0.1):
text = f"This PR decreases type completeness by {round(base - pr, 3)}. ❌"
base_text = f"This PR changes type completeness from {round(base, 3)} to {round(pr, 3)}."
if pr < (base - 0.001):
text = f"{base_text} ❌"
set_summary(text)
print(Path("pr.readable").read_text(encoding="utf-8"))
error(f"{text}\n{base_text}")
error(text)
exit(1)
elif pr > (base + 0.1):
text = f"This PR increases type completeness by {round(pr - base, 3)}. ✨"
elif pr > (base + 0.001):
text = f"{base_text} ✨"
set_summary(text)
if pr < 1:
print(Path("pr.readable").read_text(encoding="utf-8"))
print(f"{text}\n{base_text}")
print(text)
else:
text = f"This PR does not change type completeness by more than 0.1. ✅"
text = f"{base_text} This is less than 0.1 percentage points. ✅"
set_summary(text)
print(Path("pr.readable").read_text(encoding="utf-8"))
print(f"{text}\n{base_text}")
print(text)

View file

@ -244,7 +244,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
self._local_mode: bool = local_mode
self._bot_user: Optional[User] = None
self._private_key: Optional[bytes] = None
self._initialized = False
self._initialized: bool = False
self._request: Tuple[BaseRequest, BaseRequest] = (
HTTPXRequest() if get_updates_request is None else get_updates_request,
@ -375,7 +375,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
# consider adding Paramspec from typing_extensions to properly fix this. Currently a workaround
def _log(func: Any): # type: ignore[no-untyped-def] # skipcq: PY-D0003
@functools.wraps(func)
async def decorator(self, *args, **kwargs): # type: ignore[no-untyped-def]
async def decorator(self: "Bot", *args: Any, **kwargs: Any) -> Any:
# pylint: disable=protected-access
self._LOGGER.debug("Entering: %s", func.__name__)
result = await func(self, *args, **kwargs) # skipcq: PYL-E1102

View file

@ -41,7 +41,7 @@ class BotDescription(TelegramObject):
def __init__(self, description: str, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs)
self.description = description
self.description: str = description
self._id_attrs = (self.description,)
@ -68,7 +68,7 @@ class BotShortDescription(TelegramObject):
def __init__(self, short_description: str, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs)
self.short_description = short_description
self.short_description: str = short_description
self._id_attrs = (self.short_description,)

View file

@ -44,7 +44,7 @@ class BotName(TelegramObject):
def __init__(self, name: str, *, api_kwargs: JSONDict = None):
super().__init__(api_kwargs=api_kwargs)
self.name = name
self.name: str = name
self._id_attrs = (self.name,)

View file

@ -16,6 +16,7 @@
#
# You should have received a copy of the GNU Lesser Public License
"""This module contains a class that represents a Telegram SwitchInlineQueryChosenChat."""
from typing import Optional
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
@ -82,11 +83,11 @@ class SwitchInlineQueryChosenChat(TelegramObject):
):
super().__init__(api_kwargs=api_kwargs)
# Optional
self.query = query
self.allow_user_chats = allow_user_chats
self.allow_bot_chats = allow_bot_chats
self.allow_group_chats = allow_group_chats
self.allow_channel_chats = allow_channel_chats
self.query: Optional[str] = query
self.allow_user_chats: Optional[bool] = allow_user_chats
self.allow_bot_chats: Optional[bool] = allow_bot_chats
self.allow_group_chats: Optional[bool] = allow_group_chats
self.allow_channel_chats: Optional[bool] = allow_channel_chats
self._id_attrs = (
self.query,