Skip to content

Commit ef22802

Browse files
committed
style: format custom emoji tools and tests with black
1 parent 2e4990b commit ef22802

2 files changed

Lines changed: 14 additions & 28 deletions

File tree

‎telegram_mcp/tools/custom_emoji.py‎

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,11 @@ async def get_custom_emoji_packs(
7878

7979
if query and query.strip():
8080
result = await cl(
81-
functions.messages.SearchEmojiStickerSetsRequest(
82-
q=query.strip(), hash=0
83-
)
81+
functions.messages.SearchEmojiStickerSetsRequest(q=query.strip(), hash=0)
8482
)
8583
raw_sets = getattr(result, "sets", []) or []
8684
elif featured:
87-
result = await cl(
88-
functions.messages.GetFeaturedEmojiStickersRequest(hash=0)
89-
)
85+
result = await cl(functions.messages.GetFeaturedEmojiStickersRequest(hash=0))
9086
raw_sets = getattr(result, "sets", []) or []
9187
else:
9288
result = await cl(functions.messages.GetEmojiStickersRequest(hash=0))
@@ -200,19 +196,13 @@ async def get_custom_emoji_pack(
200196
alt = getattr(attr, "alt", alt) or alt
201197

202198
mime_type = getattr(doc, "mime_type", "")
203-
is_animated = (
204-
mime_type == "application/x-tgsticker"
205-
or any(
206-
isinstance(a, types.DocumentAttributeAnimated)
207-
for a in getattr(doc, "attributes", []) or []
208-
)
199+
is_animated = mime_type == "application/x-tgsticker" or any(
200+
isinstance(a, types.DocumentAttributeAnimated)
201+
for a in getattr(doc, "attributes", []) or []
209202
)
210-
is_video = (
211-
mime_type == "video/webm"
212-
or any(
213-
isinstance(a, types.DocumentAttributeVideo)
214-
for a in getattr(doc, "attributes", []) or []
215-
)
203+
is_video = mime_type == "video/webm" or any(
204+
isinstance(a, types.DocumentAttributeVideo)
205+
for a in getattr(doc, "attributes", []) or []
216206
)
217207
if is_animated:
218208
fmt = "animated"
@@ -233,9 +223,7 @@ async def get_custom_emoji_pack(
233223
}
234224
)
235225

236-
return json.dumps(
237-
{"pack": pack_info, "emojis": emojis}, indent=2, default=json_serializer
238-
)
226+
return json.dumps({"pack": pack_info, "emojis": emojis}, indent=2, default=json_serializer)
239227
except Exception as e:
240228
return log_and_format_error("get_custom_emoji_pack", e, pack=pack)
241229

@@ -273,9 +261,7 @@ async def preview_custom_emoji(
273261
cl = get_client(account)
274262
await ensure_connected(cl)
275263

276-
docs = await cl(
277-
functions.messages.GetCustomEmojiDocumentsRequest(document_id=[doc_id])
278-
)
264+
docs = await cl(functions.messages.GetCustomEmojiDocumentsRequest(document_id=[doc_id]))
279265
if not docs:
280266
return f"Custom emoji with document ID {doc_id} not found."
281267

‎tests/test_custom_emoji_packs.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ async def test_get_custom_emoji_packs_featured(monkeypatch):
158158
cl = AsyncMock()
159159
s = _mock_sticker_set(id=10, title="Featured Pack", short_name="feat_pack")
160160
covered = types.StickerSetCovered(set=s, cover=types.DocumentEmpty(id=1))
161-
cl.return_value = types.messages.FeaturedStickers(
162-
hash=0, count=1, sets=[covered], unread=[]
163-
)
161+
cl.return_value = types.messages.FeaturedStickers(hash=0, count=1, sets=[covered], unread=[])
164162

165163
monkeypatch.setattr(custom_emoji, "get_client", lambda account=None: cl)
166164
monkeypatch.setattr(custom_emoji, "ensure_connected", AsyncMock())
@@ -223,7 +221,9 @@ async def test_get_custom_emoji_packs_error(monkeypatch):
223221
@pytest.mark.asyncio
224222
async def test_get_custom_emoji_pack_success(monkeypatch):
225223
cl = AsyncMock()
226-
s_meta = _mock_sticker_set(id=100, title="Duck Pack", short_name="duck_pack", count=2, emojis=True)
224+
s_meta = _mock_sticker_set(
225+
id=100, title="Duck Pack", short_name="duck_pack", count=2, emojis=True
226+
)
227227
doc1 = _mock_custom_emoji_doc(doc_id=101, alt="🦆", free=True, mime_type="image/webp")
228228
doc2 = _mock_custom_emoji_doc(
229229
doc_id=102, alt="🔥", free=False, mime_type="application/x-tgsticker", is_animated=True

0 commit comments

Comments
 (0)