mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 06:25:12 +01:00
Bump ruff
and Remove sort-all
(#4075)
This commit is contained in:
parent
b73dc5728e
commit
2d63c57ed6
12 changed files with 44 additions and 43 deletions
|
@ -77,7 +77,7 @@ repos:
|
|||
- --diff
|
||||
- --check
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.1.9'
|
||||
rev: 'v0.1.14'
|
||||
hooks:
|
||||
- id: ruff
|
||||
name: ruff
|
||||
|
@ -88,9 +88,3 @@ repos:
|
|||
- APScheduler~=3.10.4
|
||||
- cachetools~=5.3.2
|
||||
- aiolimiter~=1.1.0
|
||||
- repo: https://github.com/aio-libs/sort-all/
|
||||
rev: v1.2.0
|
||||
hooks:
|
||||
- id: sort-all
|
||||
name: sort-all
|
||||
files: ^(telegram|examples|tests)/.*\.py$
|
||||
|
|
|
@ -12,9 +12,15 @@ target-version = "py38"
|
|||
show-fixes = 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"]
|
||||
"G", "ISC", "PT", "ASYNC", "TCH", "SLOT", "PERF", "PYI", "FLY", "AIR", "RUF022", "Q",
|
||||
"INP",]
|
||||
|
||||
# Add "FURB" after it's out of preview
|
||||
|
||||
[tool.ruff.lint]
|
||||
preview = true
|
||||
explicit-preview-rules = true
|
||||
|
||||
[tool.ruff.per-file-ignores]
|
||||
"tests/*.py" = ["B018"]
|
||||
"tests/**.py" = ["RUF012"]
|
||||
|
|
|
@ -64,6 +64,7 @@ disallow_untyped_defs = True
|
|||
disallow_incomplete_defs = True
|
||||
disallow_untyped_decorators = True
|
||||
show_error_codes = True
|
||||
python_version = 3.8
|
||||
|
||||
# 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
|
||||
|
|
|
@ -75,8 +75,8 @@ class InputLocationMessageContent(InputMessageContent):
|
|||
|
||||
"""
|
||||
|
||||
__slots__ = ('longitude', 'horizontal_accuracy', 'proximity_alert_radius', 'live_period',
|
||||
'latitude', 'heading')
|
||||
__slots__ = ("longitude", "horizontal_accuracy", "proximity_alert_radius", "live_period",
|
||||
"latitude", "heading")
|
||||
# fmt: on
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -60,7 +60,7 @@ class StringEnum(str, _enum.Enum):
|
|||
|
||||
|
||||
# Apply the __repr__ modification and __str__ fix to IntEnum
|
||||
class IntEnum(_enum.IntEnum):
|
||||
class IntEnum(_enum.IntEnum): # pylint: disable=invalid-slots
|
||||
"""Helper class for int enums where ``str(member)`` prints the value, but ``repr(member)``
|
||||
gives ``EnumName.MEMBER_NAME``.
|
||||
"""
|
||||
|
|
|
@ -29,11 +29,12 @@ those classes.
|
|||
* Most of the constants in this module are grouped into enums.
|
||||
"""
|
||||
# TODO: Remove this when https://github.com/PyCQA/pylint/issues/6887 is resolved.
|
||||
# pylint: disable=invalid-enum-extension
|
||||
# pylint: disable=invalid-enum-extension,invalid-slots
|
||||
|
||||
__all__ = [
|
||||
"BOT_API_VERSION",
|
||||
"BOT_API_VERSION_INFO",
|
||||
"SUPPORTED_WEBHOOK_PORTS",
|
||||
"BotCommandLimit",
|
||||
"BotCommandScopeType",
|
||||
"BotDescriptionLimit",
|
||||
|
@ -75,7 +76,6 @@ __all__ = [
|
|||
"PollType",
|
||||
"PollingLimit",
|
||||
"ReplyLimit",
|
||||
"SUPPORTED_WEBHOOK_PORTS",
|
||||
"StickerFormat",
|
||||
"StickerLimit",
|
||||
"StickerSetLimit",
|
||||
|
|
|
@ -81,7 +81,7 @@ class TrackingDict(UserDict, Generic[_KT, _VT]):
|
|||
:attr:`DELETED`.
|
||||
"""
|
||||
keys = self.pop_accessed_keys()
|
||||
return [(key, self[key] if key in self else self.DELETED) for key in keys]
|
||||
return [(key, self.get(key, self.DELETED)) for key in keys]
|
||||
|
||||
def mark_as_accessed(self, key: _KT) -> None:
|
||||
"""Use this method have the key returned again in the next call to
|
||||
|
|
|
@ -41,11 +41,34 @@ __all__ = (
|
|||
"ANIMATION",
|
||||
"ATTACHMENT",
|
||||
"AUDIO",
|
||||
"BaseFilter",
|
||||
"CAPTION",
|
||||
"CHAT",
|
||||
"COMMAND",
|
||||
"CONTACT",
|
||||
"FORWARDED",
|
||||
"GAME",
|
||||
"HAS_MEDIA_SPOILER",
|
||||
"HAS_PROTECTED_CONTENT",
|
||||
"INVOICE",
|
||||
"IS_AUTOMATIC_FORWARD",
|
||||
"IS_TOPIC_MESSAGE",
|
||||
"LOCATION",
|
||||
"PASSPORT_DATA",
|
||||
"PHOTO",
|
||||
"POLL",
|
||||
"PREMIUM_USER",
|
||||
"REPLY",
|
||||
"STORY",
|
||||
"SUCCESSFUL_PAYMENT",
|
||||
"TEXT",
|
||||
"USER",
|
||||
"USER_ATTACHMENT",
|
||||
"VENUE",
|
||||
"VIA_BOT",
|
||||
"VIDEO",
|
||||
"VIDEO_NOTE",
|
||||
"VOICE",
|
||||
"BaseFilter",
|
||||
"Caption",
|
||||
"CaptionEntity",
|
||||
"CaptionRegex",
|
||||
|
@ -55,42 +78,19 @@ __all__ = (
|
|||
"Dice",
|
||||
"Document",
|
||||
"Entity",
|
||||
"FORWARDED",
|
||||
"ForwardedFrom",
|
||||
"GAME",
|
||||
"HAS_MEDIA_SPOILER",
|
||||
"HAS_PROTECTED_CONTENT",
|
||||
"INVOICE",
|
||||
"IS_AUTOMATIC_FORWARD",
|
||||
"IS_TOPIC_MESSAGE",
|
||||
"LOCATION",
|
||||
"Language",
|
||||
"Mention",
|
||||
"MessageFilter",
|
||||
"PASSPORT_DATA",
|
||||
"PHOTO",
|
||||
"POLL",
|
||||
"PREMIUM_USER",
|
||||
"REPLY",
|
||||
"Regex",
|
||||
"STORY",
|
||||
"SUCCESSFUL_PAYMENT",
|
||||
"SenderChat",
|
||||
"StatusUpdate",
|
||||
"Sticker",
|
||||
"SuccessfulPayment",
|
||||
"TEXT",
|
||||
"Text",
|
||||
"USER",
|
||||
"USER_ATTACHMENT",
|
||||
"UpdateFilter",
|
||||
"UpdateType",
|
||||
"User",
|
||||
"VENUE",
|
||||
"VIA_BOT",
|
||||
"VIDEO",
|
||||
"VIDEO_NOTE",
|
||||
"VOICE",
|
||||
"ViaBot",
|
||||
)
|
||||
import mimetypes
|
||||
|
|
|
@ -339,7 +339,7 @@ async def check_defaults_handling(
|
|||
|
||||
# Check InputMedia (parse_mode can have a default)
|
||||
def check_input_media(m: Dict):
|
||||
parse_mode = m.get("parse_mode", None)
|
||||
parse_mode = m.get("parse_mode")
|
||||
if df_value is DEFAULT_NONE:
|
||||
if parse_mode is not None:
|
||||
pytest.fail("InputMedia has non-None parse_mode")
|
||||
|
|
|
@ -160,7 +160,7 @@ async def default_bot(request, bot_info):
|
|||
defaults = Defaults(**param)
|
||||
|
||||
# If the bot is already created, return it. Else make a new one.
|
||||
default_bot = _default_bots.get(defaults, None)
|
||||
default_bot = _default_bots.get(defaults)
|
||||
if default_bot is None:
|
||||
default_bot = make_bot(bot_info, defaults=defaults)
|
||||
await default_bot.initialize()
|
||||
|
|
|
@ -159,8 +159,8 @@ class TestCallbackDataCache:
|
|||
out2 = cdc.process_keyboard(reply_markup)
|
||||
assert len(cdc.persistence_data[0]) == 1
|
||||
|
||||
keyboard_1, button_1 = cdc.extract_uuids(out1.inline_keyboard[0][1].callback_data)
|
||||
keyboard_2, button_2 = cdc.extract_uuids(out2.inline_keyboard[0][2].callback_data)
|
||||
keyboard_1, _ = cdc.extract_uuids(out1.inline_keyboard[0][1].callback_data)
|
||||
keyboard_2, _ = cdc.extract_uuids(out2.inline_keyboard[0][2].callback_data)
|
||||
assert cdc.persistence_data[0][0][0] != keyboard_1
|
||||
assert cdc.persistence_data[0][0][0] == keyboard_2
|
||||
|
||||
|
|
|
@ -460,7 +460,7 @@ class TestTelegramObject:
|
|||
"and can therefore not be frozen correctly"
|
||||
)
|
||||
|
||||
source_lines, first_line = inspect.getsourcelines(cls.__init__)
|
||||
source_lines, _ = inspect.getsourcelines(cls.__init__)
|
||||
|
||||
# We use regex matching since a simple "if self._freeze() in source_lines[-1]" would also
|
||||
# allo commented lines.
|
||||
|
|
Loading…
Reference in a new issue