Add New Rules to ruff Config (#4250)

This commit is contained in:
Harshil 2024-05-12 03:13:20 -04:00 committed by GitHub
parent 5b0e0b5f78
commit f3bd0f1462
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 59 additions and 54 deletions

View file

@ -20,13 +20,15 @@ explicit-preview-rules = true
ignore = ["PLR2004", "PLR0911", "PLR0912", "PLR0913", "PLR0915", "PERF203"]
select = ["E", "F", "I", "PL", "UP", "RUF", "PTH", "C4", "B", "PIE", "SIM", "RET", "RSE",
"G", "ISC", "PT", "ASYNC", "TCH", "SLOT", "PERF", "PYI", "FLY", "AIR", "RUF022",
"RUF023", "Q", "INP", "W"]
"RUF023", "Q", "INP", "W", "YTT", "DTZ", "ARG"]
# Add "FURB" after it's out of preview
# Add "A (flake8-builtins)" after we drop pylint
[tool.ruff.lint.per-file-ignores]
"tests/*.py" = ["B018"]
"tests/**.py" = ["RUF012", "ASYNC101"]
"docs/**.py" = ["INP001"]
"tests/**.py" = ["RUF012", "ASYNC101", "DTZ", "ARG"]
"docs/**.py" = ["INP001", "ARG"]
"examples/**.py" = ["ARG"]
# PYLINT:
[tool.pylint."messages control"]

View file

@ -8850,7 +8850,7 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
api_kwargs=api_kwargs,
)
def to_dict(self, recursive: bool = True) -> JSONDict:
def to_dict(self, recursive: bool = True) -> JSONDict: # noqa: ARG002
"""See :meth:`telegram.TelegramObject.to_dict`."""
data: JSONDict = {"id": self.id, "username": self.username, "first_name": self.first_name}

View file

@ -198,7 +198,7 @@ class MaybeInaccessibleMessage(TelegramObject):
data["date"] = from_timestamp(data["date"], tzinfo=loc_tzinfo)
data["chat"] = Chat.de_json(data.get("chat"), bot)
return super()._de_json(data=data, bot=bot)
return super()._de_json(data=data, bot=bot, api_kwargs=api_kwargs)
class InaccessibleMessage(MaybeInaccessibleMessage):

View file

@ -157,7 +157,10 @@ class EncryptedPassportElement(TelegramObject):
reverse_side: Optional[PassportFile] = None,
selfie: Optional[PassportFile] = None,
translation: Optional[Sequence[PassportFile]] = None,
credentials: Optional["Credentials"] = None, # pylint: disable=unused-argument
# TODO: Remove the credentials argument in 22.0 or later
credentials: Optional[ # pylint: disable=unused-argument # noqa: ARG002
"Credentials"
] = None,
*,
api_kwargs: Optional[JSONDict] = None,
):

View file

@ -208,7 +208,7 @@ class AIORateLimiter(BaseRateLimiter[int]):
callback: Callable[..., Coroutine[Any, Any, Union[bool, JSONDict, List[JSONDict]]]],
args: Any,
kwargs: Dict[str, Any],
endpoint: str,
endpoint: str, # noqa: ARG002
data: Dict[str, Any],
rate_limit_args: Optional[int],
) -> Union[bool, JSONDict, List[JSONDict]]:

View file

@ -163,7 +163,7 @@ class BasePersistence(Generic[UD, CD, BD], ABC):
return self._update_interval
@update_interval.setter
def update_interval(self, value: object) -> NoReturn:
def update_interval(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to update_interval after initialization."
)

View file

@ -165,7 +165,7 @@ class SimpleUpdateProcessor(BaseUpdateProcessor):
async def do_process_update(
self,
update: object,
update: object, # noqa: ARG002
coroutine: "Awaitable[Any]",
) -> None:
"""Immediately awaits the coroutine, i.e. does not apply any additional processing.

View file

@ -165,7 +165,7 @@ class CallbackContext(Generic[BT, UD, CD, BD]):
return self.application.bot_data
@bot_data.setter
def bot_data(self, value: object) -> NoReturn:
def bot_data(self, _: object) -> NoReturn:
raise AttributeError(
f"You can not assign a new value to bot_data, see {_STORING_DATA_WIKI}"
)
@ -192,7 +192,7 @@ class CallbackContext(Generic[BT, UD, CD, BD]):
return None
@chat_data.setter
def chat_data(self, value: object) -> NoReturn:
def chat_data(self, _: object) -> NoReturn:
raise AttributeError(
f"You can not assign a new value to chat_data, see {_STORING_DATA_WIKI}"
)
@ -214,7 +214,7 @@ class CallbackContext(Generic[BT, UD, CD, BD]):
return None
@user_data.setter
def user_data(self, value: object) -> NoReturn:
def user_data(self, _: object) -> NoReturn:
raise AttributeError(
f"You can not assign a new value to user_data, see {_STORING_DATA_WIKI}"
)

View file

@ -235,7 +235,7 @@ class Defaults:
return self._parse_mode
@parse_mode.setter
def parse_mode(self, value: object) -> NoReturn:
def parse_mode(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to parse_mode after initialization.")
@property
@ -246,7 +246,7 @@ class Defaults:
return self._parse_mode
@explanation_parse_mode.setter
def explanation_parse_mode(self, value: object) -> NoReturn:
def explanation_parse_mode(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to explanation_parse_mode after initialization."
)
@ -259,7 +259,7 @@ class Defaults:
return self._parse_mode
@quote_parse_mode.setter
def quote_parse_mode(self, value: object) -> NoReturn:
def quote_parse_mode(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to quote_parse_mode after initialization."
)
@ -272,7 +272,7 @@ class Defaults:
return self._disable_notification
@disable_notification.setter
def disable_notification(self, value: object) -> NoReturn:
def disable_notification(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to disable_notification after initialization."
)
@ -289,7 +289,7 @@ class Defaults:
return self._link_preview_options.is_disabled if self._link_preview_options else None
@disable_web_page_preview.setter
def disable_web_page_preview(self, value: object) -> NoReturn:
def disable_web_page_preview(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to disable_web_page_preview after initialization."
)
@ -302,7 +302,7 @@ class Defaults:
return self._allow_sending_without_reply
@allow_sending_without_reply.setter
def allow_sending_without_reply(self, value: object) -> NoReturn:
def allow_sending_without_reply(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to allow_sending_without_reply after initialization."
)
@ -318,7 +318,7 @@ class Defaults:
return self._do_quote if self._do_quote is not None else None
@quote.setter
def quote(self, value: object) -> NoReturn:
def quote(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to quote after initialization.")
@property
@ -329,7 +329,7 @@ class Defaults:
return self._tzinfo
@tzinfo.setter
def tzinfo(self, value: object) -> NoReturn:
def tzinfo(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to tzinfo after initialization.")
@property
@ -341,7 +341,7 @@ class Defaults:
return self._block
@block.setter
def block(self, value: object) -> NoReturn:
def block(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to block after initialization.")
@property
@ -354,7 +354,7 @@ class Defaults:
return self._protect_content
@protect_content.setter
def protect_content(self, value: object) -> NoReturn:
def protect_content(self, _: object) -> NoReturn:
raise AttributeError(
"You can't assign a new value to protect_content after initialization."
)

View file

@ -159,8 +159,8 @@ class CallbackQueryHandler(BaseHandler[Update, CCT]):
def collect_additional_context(
self,
context: CCT,
update: Update,
application: "Application[Any, CCT, Any, Any, Any, Any]",
update: Update, # noqa: ARG002
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
check_result: Union[bool, Match[str]],
) -> None:
"""Add the result of ``re.match(pattern, update.callback_query.data)`` to

View file

@ -109,8 +109,8 @@ class ChosenInlineResultHandler(BaseHandler[Update, CCT]):
def collect_additional_context(
self,
context: CCT,
update: Update,
application: "Application[Any, CCT, Any, Any, Any, Any]",
update: Update, # noqa: ARG002
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
check_result: Union[bool, Match[str]],
) -> None:
"""This function adds the matched regex pattern result to

View file

@ -204,8 +204,8 @@ class CommandHandler(BaseHandler[Update, CCT]):
def collect_additional_context(
self,
context: CCT,
update: Update,
application: "Application[Any, CCT, Any, Any, Any, Any]",
update: Update, # noqa: ARG002
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]],
) -> None:
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single

View file

@ -473,7 +473,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._entry_points
@entry_points.setter
def entry_points(self, value: object) -> NoReturn:
def entry_points(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to entry_points after initialization."
)
@ -487,7 +487,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._states
@states.setter
def states(self, value: object) -> NoReturn:
def states(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to states after initialization.")
@property
@ -499,7 +499,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._fallbacks
@fallbacks.setter
def fallbacks(self, value: object) -> NoReturn:
def fallbacks(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to fallbacks after initialization.")
@property
@ -508,7 +508,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._allow_reentry
@allow_reentry.setter
def allow_reentry(self, value: object) -> NoReturn:
def allow_reentry(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to allow_reentry after initialization."
)
@ -519,7 +519,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._per_user
@per_user.setter
def per_user(self, value: object) -> NoReturn:
def per_user(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to per_user after initialization.")
@property
@ -528,7 +528,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._per_chat
@per_chat.setter
def per_chat(self, value: object) -> NoReturn:
def per_chat(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to per_chat after initialization.")
@property
@ -537,7 +537,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._per_message
@per_message.setter
def per_message(self, value: object) -> NoReturn:
def per_message(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to per_message after initialization.")
@property
@ -551,7 +551,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._conversation_timeout
@conversation_timeout.setter
def conversation_timeout(self, value: object) -> NoReturn:
def conversation_timeout(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to conversation_timeout after initialization."
)
@ -562,7 +562,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._name
@name.setter
def name(self, value: object) -> NoReturn:
def name(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to name after initialization.")
@property
@ -574,7 +574,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._persistent
@persistent.setter
def persistent(self, value: object) -> NoReturn:
def persistent(self, _: object) -> NoReturn:
raise AttributeError("You can not assign a new value to persistent after initialization.")
@property
@ -586,7 +586,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
return self._map_to_parent
@map_to_parent.setter
def map_to_parent(self, value: object) -> NoReturn:
def map_to_parent(self, _: object) -> NoReturn:
raise AttributeError(
"You can not assign a new value to map_to_parent after initialization."
)

View file

@ -130,8 +130,8 @@ class InlineQueryHandler(BaseHandler[Update, CCT]):
def collect_additional_context(
self,
context: CCT,
update: Update,
application: "Application[Any, CCT, Any, Any, Any, Any]",
update: Update, # noqa: ARG002
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
check_result: Optional[Union[bool, Match[str]]],
) -> None:
"""Add the result of ``re.match(pattern, update.inline_query.query)`` to

View file

@ -102,8 +102,8 @@ class MessageHandler(BaseHandler[Update, CCT]):
def collect_additional_context(
self,
context: CCT,
update: Update,
application: "Application[Any, CCT, Any, Any, Any, Any]",
update: Update, # noqa: ARG002
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
check_result: Optional[Union[bool, Dict[str, object]]],
) -> None:
"""Adds possible output of data filters to the :class:`CallbackContext`."""

View file

@ -171,8 +171,8 @@ class PrefixHandler(BaseHandler[Update, CCT]):
def collect_additional_context(
self,
context: CCT,
update: Update,
application: "Application[Any, CCT, Any, Any, Any, Any]",
update: Update, # noqa: ARG002
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]],
) -> None:
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single

View file

@ -98,8 +98,8 @@ class StringCommandHandler(BaseHandler[str, CCT]):
def collect_additional_context(
self,
context: CCT,
update: str,
application: "Application[Any, CCT, Any, Any, Any, Any]",
update: str, # noqa: ARG002
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
check_result: Optional[List[str]],
) -> None:
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single

View file

@ -103,8 +103,8 @@ class StringRegexHandler(BaseHandler[str, CCT]):
def collect_additional_context(
self,
context: CCT,
update: str,
application: "Application[Any, CCT, Any, Any, Any, Any]",
update: str, # noqa: ARG002
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
check_result: Optional[Match[str]],
) -> None:
"""Add the result of ``re.match(pattern, update)`` to :attr:`CallbackContext.matches` as

View file

@ -401,7 +401,7 @@ class _InvertedFilter(UpdateFilter):
return f"<inverted {self.inv_filter}>"
@name.setter
def name(self, name: str) -> NoReturn:
def name(self, _: str) -> NoReturn:
raise RuntimeError("Cannot set name for combined filters.")
@ -492,7 +492,7 @@ class _MergedFilter(UpdateFilter):
)
@name.setter
def name(self, name: str) -> NoReturn:
def name(self, _: str) -> NoReturn:
raise RuntimeError("Cannot set name for combined filters.")
@ -522,14 +522,14 @@ class _XORFilter(UpdateFilter):
return f"<{self.base_filter} xor {self.xor_filter}>"
@name.setter
def name(self, name: str) -> NoReturn:
def name(self, _: str) -> NoReturn:
raise RuntimeError("Cannot set name for combined filters.")
class _All(MessageFilter):
__slots__ = ()
def filter(self, message: Message) -> bool:
def filter(self, message: Message) -> bool: # noqa: ARG002
return True
@ -809,7 +809,7 @@ class _ChatUserBaseFilter(MessageFilter, ABC):
)
@name.setter
def name(self, name: str) -> NoReturn:
def name(self, _: str) -> NoReturn:
raise RuntimeError(f"Cannot set name for filters.{self.__class__.__name__}")