8000 Add New Rules to `ruff` Config (#4250) · gtkacz/python-telegram-bot@f3bd0f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3bd0f1

Browse files
authored
Add New Rules to ruff Config (python-telegram-bot#4250)
1 parent 5b0e0b5 commit f3bd0f1

19 files changed

+59
-54
lines changed

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ explicit-preview-rules = true
2020
ignore = ["PLR2004", "PLR0911", "PLR0912", "PLR0913", "PLR0915", "PERF203"]
2121
select = ["E", "F", "I", "PL", "UP", "RUF", "PTH", "C4", "B", "PIE", "SIM", "RET", "RSE",
2222
"G", "ISC", "PT", "ASYNC", "TCH", "SLOT", "PERF", "PYI", "FLY", "AIR", "RUF022",
23-
"RUF023", "Q", "INP", "W"]
23+
"RUF023", "Q", "INP", "W", "YTT", "DTZ", "ARG"]
2424
# Add "FURB" after it's out of preview
25+
# Add "A (flake8-builtins)" after we drop pylint
2526

2627
[tool.ruff.lint.per-file-ignores]
2728
"tests/*.py" = ["B018"]
28-
"tests/**.py" = ["RUF012", "ASYNC101"]
29-
"docs/**.py" = ["INP001"]
29+
"tests/**.py" = ["RUF012", "ASYNC101", "DTZ", "ARG"]
30+
"docs/**.py" = ["INP001", "ARG"]
31+
"examples/**.py" = ["ARG"]
3032

3133
# PYLINT:
3234
[tool.pylint."messages control"]

telegram/_bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8850,7 +8850,7 @@ async def replace_sticker_in_set(
88508850
api_kwargs=api_kwargs,
88518851
)
88528852

8853-
def to_dict(self, recursive: bool = True) -> JSONDict:
8853+
def to_dict(self, recursive: bool = True) -> JSONDict: # noqa: ARG002
88548854
"""See :meth:`telegram.TelegramObject.to_dict`."""
88558855
data: JSONDict = {"id": self.id, "username": self.username, "first_name": self.first_name}
88568856

telegram/_message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _de_json(
198198
data["date"] = from_timestamp(data["date"], tzinfo=loc_tzinfo)
199199

200200
data["chat"] = Chat.de_json(data.get("chat"), bot)
201-
return super()._de_json(data=data, bot=bot)
201+
return super()._de_json(data=data, bot=bot, api_kwargs=api_kwargs)
202202

203203

204204
class InaccessibleMessage(MaybeInaccessibleMessage):

telegram/_passport/encryptedpassportelement.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ def __init__(
157157
reverse_side: Optional[PassportFile] = None,
158158
selfie: Optional[PassportFile] = None,
159159
translation: Optional[Sequence[PassportFile]] = None,
160-
credentials: Optional["Credentials"] = None, # pylint: disable=unused-argument
160+
# TODO: Remove the credentials argument in 22.0 or later
161+
credentials: Optional[ # pylint: disable=unused-argument # noqa: ARG002
162+
"Credentials"
163+
] = None,
161164
*,
162165
api_kwargs: Optional[JSONDict] = None,
163166
):

telegram/ext/_aioratelimiter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ async def process_request(
208208
callback: Callable[..., Coroutine[Any, Any, Union[bool, JSONDict, List[JSONDict]]]],
209209
args: Any,
210210
kwargs: Dict[str, Any],
211-
endpoint: str,
211+
endpoint: str, # noqa: ARG002
212212
data: Dict[str, Any],
213213
rate_limit_args: Optional[int],
214214
) -> Union[bool, JSONDict, List[JSONDict]]:

telegram/ext/_basepersistence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def update_interval(self) -> float:
163163
return self._update_interval
164164

165165
@update_interval.setter
166-
def update_interval(self, value: object) -> NoReturn:
166+
def update_interval(self, _: object) -> NoReturn:
167167
raise AttributeError(
168168
"You can not assign a new value to update_interval after initialization."
169169
)

telegram/ext/_baseupdateprocessor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class SimpleUpdateProcessor(BaseUpdateProcessor):
165165

166166
async def do_process_update(
167167
self,
168-
update: object,
168+
update: object, # noqa: ARG002
169169
coroutine: "Awaitable[Any]",
170170
) -> None:
171171
"""Immediately awaits the coroutine, i.e. does not apply any additional processing.

telegram/ext/_callbackcontext.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def bot_data(self) -> BD:
165165
return self.application.bot_data
166166

167167
@bot_data.setter
168-
def bot_data(self, value: object) -> NoReturn:
168+
def bot_data(self, _: object) -> NoReturn:
169169
raise AttributeError(
170170
f"You can not assign a new value to bot_data, see {_STORING_DATA_WIKI}"
171171
)
@@ -192,7 +192,7 @@ def chat_data(self) -> Optional[CD]:
192192
return None
193193

194194
@chat_data.setter
195-
def chat_data(self, value: object) -> NoReturn:
195+
def chat_data(self, _: object) -> NoReturn:
196196
raise AttributeError(
197197
f"You can not assign a new value to chat_data, see {_STORING_DATA_WIKI}"
198198
)
@@ -214,7 +214,7 @@ def user_data(self) -> Optional[UD]:
214214
return None
215215

216216
@user_data.setter
217-
def user_data(self, value: object) -> NoReturn:
217+
def user_data(self, _: object) -> NoReturn:
218218
raise AttributeError(
219219
f"You can not assign a new value to user_data, see {_STORING_DATA_WIKI}"
220220
)

telegram/ext/_defaults.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def parse_mode(self) -> Optional[str]:
235235
return self._parse_mode
236236

237237
@parse_mode.setter
238-
def parse_mode(self, value: object) -> NoReturn:
238+
def parse_mode(self, _: object) -> NoReturn:
239239
raise AttributeError("You can not assign a new value to parse_mode after initialization.")
240240

241241
@property
@@ -246,7 +246,7 @@ def explanation_parse_mode(self) -> Optional[str]:
246246
return self._parse_mode
247247

248248
@explanation_parse_mode.setter
249-
def explanation_parse_mode(self, value: object) -> NoReturn:
249+
def explanation_parse_mode(self, _: object) -> NoReturn:
250250
raise AttributeError(
251251
"You can not assign a new value to explanation_parse_mode after initialization."
252252
)
@@ -259,7 +259,7 @@ def quote_parse_mode(self) -> Optional[str]:
259259
return self._parse_mode
260260

261261
@quote_parse_mode.setter
262-
def quote_parse_mode(self, value: object) -> NoReturn:
262+
def quote_parse_mode(self, _: object) -> NoReturn:
263263
raise AttributeError(
264264
"You can not assign a new value to quote_parse_mode after initialization."
265265
)
@@ -272,7 +272,7 @@ def disable_notification(self) -> Optional[bool]:
272272
return self._disable_notification
273273

274274
@disable_notification.setter
275-
def disable_notification(self, value: object) -> NoReturn:
275+
def disable_notification(self, _: object) -> NoReturn:
276276
raise AttributeError(
277277
"You can not assign a new value to disable_notification after initialization."
278278
)
@@ -289,7 +289,7 @@ def disable_web_page_preview(self) -> ODVInput[bool]:
289289
return self._link_preview_options.is_disabled if self._link_preview_options else None
290290

291291
@disable_web_page_preview.setter
292-
def disable_web_page_preview(self, value: object) -> NoReturn:
292+
def disable_web_page_preview(self, _: object) -> NoReturn:
293293
raise AttributeError(
294294
"You can not assign a new value to disable_web_page_preview after initialization."
295295
)
@@ -302,7 +302,7 @@ def allow_sending_without_reply(self) -> Optional[bool]:
302302
return self._allow_sending_without_reply
303303

304304
@allow_sending_without_reply.setter
305-
def allow_sending_without_reply(self, value: object) -> NoReturn:
305+
def allow_sending_without_reply(self, _: object) -> NoReturn:
306306
raise AttributeError(
307307
"You can not assign a new value to allow_sending_without_reply after initialization."
308308
)
@@ -318,7 +318,7 @@ def quote(self) -> Optional[bool]:
318318
return self._do_quote if self._do_quote is not None else None
319319

320320
@quote.setter
321-
def quote(self, value: object) -> NoReturn:
321+
def quote(self, _: object) -> NoReturn:
322322
raise AttributeError("You can not assign a new value to quote after initialization.")
323323

324324
@property
@@ -329,7 +329,7 @@ def tzinfo(self) -> datetime.tzinfo:
329329
return self._tzinfo
330330

331331
@tzinfo.setter
332-
def tzinfo(self, value: object) -> NoReturn:
332+
def tzinfo(self, _: object) -> NoReturn:
333333
raise AttributeError("You can not assign a new value to tzinfo after initialization.")
334334

335335
@property
@@ -341,7 +341,7 @@ def block(self) -> bool:
341341
return self._block
342342

343343
@block.setter
344-
def block(self, value: object) -> NoReturn:
344+
def block(self, _: object) -> NoReturn:
345345
raise AttributeError("You can not assign a new value to block after initialization.")
346346

347347
@property
@@ -354,7 +354,7 @@ def protect_content(self) -> Optional[bool]:
354354
return self._protect_content
355355

356356
@protect_content.setter
357-
def protect_content(self, value: object) -> NoReturn:
357+
def protect_content(self, _: object) -> NoReturn:
358358
raise AttributeError(
359359
"You can't assign a new value to protect_content after initialization."
360360
)

telegram/ext/_handlers/callbackqueryhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ def check_update(self, update: object) -> Optional[Union[bool, object]]:
159159
def collect_additional_context(
160160
self,
161161
context: CCT,
162-
update: Update,
163-
application: "Application[Any, CCT, Any, Any, Any, Any]",
162+
update: Update, # noqa: ARG002
163+
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
164164
check_result: Union[bool, Match[str]],
165165
) -> None:
166166
"""Add the result of ``re.match(pattern, update.callback_query.data)`` to

telegram/ext/_handlers/choseninlineresulthandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ def check_update(self, update: object) -> Optional[Union[bool, object]]:
109109
def collect_additional_context(
110110
self,
111111
context: CCT,
112-
update: Update,
113-
application: "Application[Any, CCT, Any, Any, Any, Any]",
112+
update: Update, # noqa: ARG002
113+
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
114114
check_result: Union[bool, Match[str]],
115115
) -> None:
116116
"""This function adds the matched regex pattern result to

telegram/ext/_handlers/commandhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ def check_update(
204204
def collect_additional_context(
205205
self,
206206
context: CCT,
207-
update: Update,
208-
application: "Application[Any, CCT, Any, Any, Any, Any]",
207+
update: Update, # noqa: ARG002
208+
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
209209
check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]],
210210
) -> None:
211211
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single

telegram/ext/_handlers/conversationhandler.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def entry_points(self) -> List[BaseHandler[Update, CCT]]:
473473
return self._entry_points
474474

475475
@entry_points.setter
476-
def entry_points(self, value: object) -> NoReturn:
476+
def entry_points(self, _: object) -> NoReturn:
477477
raise AttributeError(
478478
"You can not assign a new value to entry_points after initialization."
479479
)
@@ -487,7 +487,7 @@ def states(self) -> Dict[object, List[BaseHandler[Update, CCT]]]:
487487
return self._states
488488

489489
@states.setter
490-
def states(self, value: object) -> NoReturn:
490+
def states(self, _: object) -> NoReturn:
491491
raise AttributeError("You can not assign a new value to states after initialization.")
492492

493493
@property
@@ -499,7 +499,7 @@ def fallbacks(self) -> List[BaseHandler[Update, CCT]]:
499499
return self._fallbacks
500500

501501
@fallbacks.setter
502-
def fallbacks(self, value: object) -> NoReturn:
502+
def fallbacks(self, _: object) -> NoReturn:
503503
raise AttributeError("You can not assign a new value to fallbacks after initialization.")
504504

505505
@property
@@ -508,7 +508,7 @@ def allow_reentry(self) -> bool:
508508
return self._allow_reentry
509509

510510
@allow_reentry.setter
511-
def allow_reentry(self, value: object) -> NoReturn:
511+
def allow_reentry(self, _: object) -> NoReturn:
512512
raise AttributeError(
513513
"You can not assign a new value to allow_reentry after initialization."
514514
)
@@ -519,7 +519,7 @@ def per_user(self) -> bool:
519519
return self._per_user
520520

521521
@per_user.setter
522-
def per_user(self, value: object) -> NoReturn:
522+
def per_user(self, _: object) -> NoReturn:
523523
raise AttributeError("You can not assign a new value to per_user after initialization.")
524524

525525
@property
@@ -528,7 +528,7 @@ def per_chat(self) -> bool:
528528
return self._per_chat
529529

530530
@per_chat.setter
531-
def per_chat(self, value: object) -> NoReturn:
531+
def per_chat(self, _: object) -> NoReturn:
532532
raise AttributeError("You can not assign a new value to per_chat after initialization.")
533533

534534
@property
@@ -537,7 +537,7 @@ def per_message(self) -> bool:
537537
return self._per_message
538538

539539
@per_message.setter
540-
def per_message(self, value: object) -> NoReturn:
540+
def per_message(self, _: object) -> NoReturn:
541541
raise AttributeError("You can not assign a new value to per_message after initialization.")
542542

543543
@property
@@ -551,7 +551,7 @@ def conversation_timeout(
551551
return self._conversation_timeout
552552

553553
@conversation_timeout.setter
554-
def conversation_timeout(self, value: object) -> NoReturn:
554+
def conversation_timeout(self, _: object) -> NoReturn:
555555
raise AttributeError(
556556
"You can not assign a new value to conversation_timeout after initialization."
557557
)
@@ -562,7 +562,7 @@ def name(self) -> Optional[str]:
562562
return self._name
563563

564564
@name.setter
565-
def name(self, value: object) -> NoReturn:
565+
def name(self, _: object) -> NoReturn:
566566
raise AttributeError("You can not assign a new value to name after initialization.")
567567

568568
@property
@@ -574,7 +574,7 @@ def persistent(self) -> bool:
574574
return self._persistent
575575

576576
@persistent.setter
577-
def persistent(self, value: object) -> NoReturn:
577+
def persistent(self, _: object) -> NoReturn:
578578
raise AttributeError("You can not assign a new value to persistent after initialization.")
579579

580580
@property
@@ -586,7 +586,7 @@ def map_to_parent(self) -> Optional[Dict[object, object]]:
586586
return self._map_to_parent
587587

588588
@map_to_parent.setter
589-
def map_to_parent(self, value: object) -> NoReturn:
589+
def map_to_parent(self, _: object) -> NoReturn:
590590
raise AttributeError(
591591
"You can not assign a new value to map_to_parent after initialization."
592592
)

telegram/ext/_handlers/inlinequeryhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def check_update(self, update: object) -> Optional[Union[bool, Match[str]]]:
130130
def collect_additional_context(
131131
self,
132132
context: CCT,
133-
update: Update,
134-
application: "Application[Any, CCT, Any, Any, Any, Any]",
133+
update: Update, # noqa: ARG002
134+
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
135135
check_result: Optional[Union[bool, Match[str]]],
136136
) -> None:
137137
"""Add the result of ``re.match(pattern, update.inline_query.query)`` to

telegram/ext/_handlers/messagehandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ def check_update(self, update: object) -> Optional[Union[bool, Dict[str, List[An
102102
def collect_additional_context(
103103
self,
104104
context: CCT,
105-
update: Update,
106-
application: "Application[Any, CCT, Any, Any, Any, Any]",
105+
update: Update, # noqa: ARG002
106+
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
107107
check_result: Optional[Union[bool, Dict[str, object]]],
108108
) -> None:
109109
"""Adds possible output of data filters to the :class:`CallbackContext`."""

telegram/ext/_handlers/prefixhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ def check_update(
171171
def collect_additional_context(
172172
self,
173173
context: CCT,
174-
update: Update,
175-
application: "Application[Any, CCT, Any, Any, Any, Any]",
174+
update: Update, # noqa: ARG002
175+
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
176176
check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]],
177177
) -> None:
178178
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single

telegram/ext/_handlers/stringcommandhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ def check_update(self, update: object) -> Optional[List[str]]:
9898
def collect_additional_context(
9999
self,
100100
context: CCT,
101-
update: str,
102-
application: "Application[Any, CCT, Any, Any, Any, Any]",
101+
update: str, # noqa: ARG002
102+
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
103103
check_result: Optional[List[str]],
104104
) -> None:
105105
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single

telegram/ext/_handlers/stringregexhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ def check_update(self, update: object) -> Optional[Match[str]]:
103103
def collect_additional_context(
104104
self,
105105
context: CCT,
106-
update: str,
107-
application: "Application[Any, CCT, Any, Any, Any, Any]",
106+
update: str, # noqa: ARG002
107+
application: "Application[Any, CCT, Any, Any, Any, Any]", # noqa: ARG002
108108
check_result: Optional[Match[str]],
109109
) -> None:
110110
"""Add the result of ``re.match(pattern, update)`` to :attr:`CallbackContext.matches` as

0 commit comments

Comments
 (0)
0