Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ ci:
autoupdate_schedule: monthly

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.2.0'
hooks:
- id: ruff
name: ruff
files: ^(telegram|examples|tests)/.*\.py$
additional_dependencies:
- httpx~=0.26.0
- tornado~=6.4
- APScheduler~=3.10.4
- cachetools~=5.3.2
- aiolimiter~=1.1.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
args:
Expand Down Expand Up @@ -70,15 +82,3 @@ repos:
args:
- --diff
- --check
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.14'
hooks:
- id: ruff
name: ruff
files: ^(telegram|examples|tests)/.*\.py$
additional_dependencies:
- httpx~=0.26.0
- tornado~=6.4
- APScheduler~=3.10.4
- cachetools~=5.3.2
- aiolimiter~=1.1.0
22 changes: 11 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,26 @@ line_length = 99
line-length = 99
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", "RUF022", "Q",
"INP",]

# Add "FURB" after it's out of preview

[tool.ruff.lint]
preview = true
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",]
# Add "FURB" after it's out of preview

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*.py" = ["B018"]
"tests/**.py" = ["RUF012"]
"tests/**.py" = ["RUF012", "ASYNC101"]

# PYLINT:
[tool.pylint."messages control"]
enable = ["useless-suppression"]
disable = ["duplicate-code", "too-many-arguments", "too-many-public-methods",
"too-few-public-methods", "broad-exception-caught", "too-many-instance-attributes",
"fixme", "missing-function-docstring", "missing-class-docstring", "too-many-locals",
disable = ["duplicate-code", "too-many-arguments", "too-many-public-methods",
"too-few-public-methods", "broad-exception-caught", "too-many-instance-attributes",
"fixme", "missing-function-docstring", "missing-class-docstring", "too-many-locals",
"too-many-lines", "too-many-branches", "too-many-statements", "cyclic-import"
]

Expand Down Expand Up @@ -121,5 +120,6 @@ omit = [
[tool.coverage.report]
exclude_also = [
"@overload",
"@abstractmethod",
"if TYPE_CHECKING:"
]
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ license_files = LICENSE, LICENSE.dual, LICENSE.lesser
[flake8]
max-line-length = 99
ignore = W503, W605
extend-ignore = E203
extend-ignore = E203, E704
exclude = setup.py, setup-raw.py docs/source/conf.py
8 changes: 4 additions & 4 deletions telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
_LOGGER = get_logger(__name__)

__slots__ = (
"_token",
"_base_url",
"_base_file_url",
"_private_key",
"_base_url",
"_bot_user",
"_request",
"_initialized",
"_local_mode",
"_private_key",
"_request",
"_token",
)

def __init__(
Expand Down
2 changes: 1 addition & 1 deletion telegram/_botcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class BotCommand(TelegramObject):

"""

__slots__ = ("description", "command")
__slots__ = ("command", "description")

def __init__(self, command: str, description: str, *, api_kwargs: Optional[JSONDict] = None):
super().__init__(api_kwargs=api_kwargs)
Expand Down
14 changes: 7 additions & 7 deletions telegram/_callbackquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ class CallbackQuery(TelegramObject):
"""

__slots__ = (
"game_short_name",
"message",
"chat_instance",
"id",
"data",
"from_user",
"game_short_name",
"id",
"inline_message_id",
"data",
"message",
)

def __init__(
Expand Down Expand Up @@ -771,9 +771,9 @@ async def copy_message(
message_thread_id=message_thread_id,
)

MAX_ANSWER_TEXT_LENGTH: Final[
int
] = constants.CallbackQueryLimit.ANSWER_CALLBACK_QUERY_TEXT_LENGTH
MAX_ANSWER_TEXT_LENGTH: Final[int] = (
constants.CallbackQueryLimit.ANSWER_CALLBACK_QUERY_TEXT_LENGTH
)
"""
:const:`telegram.constants.CallbackQueryLimit.ANSWER_CALLBACK_QUERY_TEXT_LENGTH`

Expand Down
50 changes: 25 additions & 25 deletions telegram/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,35 +286,35 @@ class Chat(TelegramObject):
"""

__slots__ = (
"active_usernames",
"bio",
"can_set_sticker_set",
"description",
"emoji_status_custom_emoji_id",
"emoji_status_expiration_date",
"first_name",
"has_aggressive_anti_spam_enabled",
"has_hidden_members",
"has_private_forwards",
"has_protected_content",
"has_restricted_voice_and_video_messages",
"id",
"type",
"invite_link",
"is_forum",
"join_by_request",
"join_to_send_messages",
"last_name",
"sticker_set_name",
"slow_mode_delay",
"linked_chat_id",
"location",
"first_name",
"message_auto_delete_time",
"permissions",
"invite_link",
"photo",
"pinned_message",
"description",
"can_set_sticker_set",
"username",
"slow_mode_delay",
"sticker_set_name",
"title",
"photo",
"linked_chat_id",
"message_auto_delete_time",
"has_protected_content",
"has_private_forwards",
"join_to_send_messages",
"join_by_request",
"has_restricted_voice_and_video_messages",
"is_forum",
"active_usernames",
"emoji_status_custom_emoji_id",
"emoji_status_expiration_date",
"has_hidden_members",
"has_aggressive_anti_spam_enabled",
"type",
"username",
)

SENDER: Final[str] = constants.ChatType.SENDER
Expand Down Expand Up @@ -392,9 +392,9 @@ def __init__(
self.location: Optional[ChatLocation] = location
self.join_to_send_messages: Optional[bool] = join_to_send_messages
self.join_by_request: Optional[bool] = join_by_request
self.has_restricted_voice_and_video_messages: Optional[
bool
] = has_restricted_voice_and_video_messages
self.has_restricted_voice_and_video_messages: Optional[bool] = (
has_restricted_voice_and_video_messages
)
self.is_forum: Optional[bool] = is_forum
self.active_usernames: Tuple[str, ...] = parse_sequence_arg(active_usernames)
self.emoji_status_custom_emoji_id: Optional[str] = emoji_status_custom_emoji_id
Expand Down
22 changes: 11 additions & 11 deletions telegram/_chatadministratorrights.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ class ChatAdministratorRights(TelegramObject):
"""

__slots__ = (
"is_anonymous",
"can_manage_chat",
"can_delete_messages",
"can_manage_video_chats",
"can_restrict_members",
"can_promote_members",
"can_change_info",
"can_invite_users",
"can_post_messages",
"can_delete_messages",
"can_delete_stories",
"can_edit_messages",
"can_pin_messages",
"can_edit_stories",
"can_invite_users",
"can_manage_chat",
"can_manage_topics",
"can_manage_video_chats",
"can_pin_messages",
"can_post_messages",
"can_post_stories",
"can_edit_stories",
"can_delete_stories",
"can_promote_members",
"can_restrict_members",
"is_anonymous",
)

def __init__(
Expand Down
6 changes: 3 additions & 3 deletions telegram/_chatinvitelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ class ChatInviteLink(TelegramObject):
"""

__slots__ = (
"invite_link",
"creates_join_request",
"creator",
"expire_date",
"invite_link",
"is_primary",
"is_revoked",
"expire_date",
"member_limit",
"name",
"creates_join_request",
"pending_join_request_count",
)

Expand Down
2 changes: 1 addition & 1 deletion telegram/_chatjoinrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ChatJoinRequest(TelegramObject):

"""

__slots__ = ("chat", "from_user", "date", "bio", "invite_link", "user_chat_id")
__slots__ = ("bio", "chat", "date", "from_user", "invite_link", "user_chat_id")

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion telegram/_chatlocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ChatLocation(TelegramObject):

"""

__slots__ = ("location", "address")
__slots__ = ("address", "location")

def __init__(
self,
Expand Down
44 changes: 22 additions & 22 deletions telegram/_chatmember.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ChatMember(TelegramObject):

"""

__slots__ = ("user", "status")
__slots__ = ("status", "user")

ADMINISTRATOR: Final[str] = constants.ChatMemberStatus.ADMINISTRATOR
""":const:`telegram.constants.ChatMemberStatus.ADMINISTRATOR`"""
Expand Down Expand Up @@ -162,7 +162,7 @@ class ChatMemberOwner(ChatMember):
this user.
"""

__slots__ = ("is_anonymous", "custom_title")
__slots__ = ("custom_title", "is_anonymous")

def __init__(
self,
Expand Down Expand Up @@ -300,22 +300,22 @@ class ChatMemberAdministrator(ChatMember):

__slots__ = (
"can_be_edited",
"is_anonymous",
"can_manage_chat",
"can_delete_messages",
"can_manage_video_chats",
"can_restrict_members",
"can_promote_members",
"can_change_info",
"can_invite_users",
"can_post_messages",
"can_delete_messages",
"can_delete_stories",
"can_edit_messages",
"can_pin_messages",
"can_edit_stories",
"can_invite_users",
"can_manage_chat",
"can_manage_topics",
"custom_title",
"can_manage_video_chats",
"can_pin_messages",
"can_post_messages",
"can_post_stories",
"can_edit_stories",
"can_delete_stories",
"can_promote_members",
"can_restrict_members",
"custom_title",
"is_anonymous",
)

def __init__(
Expand Down Expand Up @@ -505,22 +505,22 @@ class ChatMemberRestricted(ChatMember):
"""

__slots__ = (
"is_member",
"can_add_web_page_previews",
"can_change_info",
"can_invite_users",
"can_pin_messages",
"can_send_messages",
"can_send_polls",
"can_send_other_messages",
"can_add_web_page_previews",
"can_manage_topics",
"until_date",
"can_pin_messages",
"can_send_audios",
"can_send_documents",
"can_send_messages",
"can_send_other_messages",
"can_send_photos",
"can_send_videos",
"can_send_polls",
"can_send_video_notes",
"can_send_videos",
"can_send_voice_notes",
"is_member",
"until_date",
)

def __init__(
Expand Down
6 changes: 3 additions & 3 deletions telegram/_chatmemberupdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ class ChatMemberUpdated(TelegramObject):

__slots__ = (
"chat",
"from_user",
"date",
"old_chat_member",
"new_chat_member",
"from_user",
"invite_link",
"new_chat_member",
"old_chat_member",
"via_chat_folder_invite_link",
)

Expand Down
Loading