Skip to content

Commit a5a316c

Browse files
author
Mehak Bindra
committed
add type stubs
1 parent a04d0be commit a5a316c

File tree

8 files changed

+173
-13
lines changed

8 files changed

+173
-13
lines changed

packages/botbuilder/pyproject.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[project]
22
name = "microsoft-teams-botbuilder"
3-
version = "2.0.0a3"
3+
version = "2.0.0a5"
44
description = "BotBuilder plugin for Microsoft Teams"
55
authors = [{ name = "Microsoft", email = "[email protected]" }]
66
readme = "README.md"
7-
requires-python = ">=3.12"
7+
requires-python = ">=3.12,<3.14"
88
repository = "https://github.com/microsoft/teams.py"
99
keywords = ["microsoft", "teams", "ai", "bot", "agents"]
1010
license = "MIT"
@@ -16,12 +16,6 @@ dependencies = [
1616
"microsoft-teams-common"
1717
]
1818

19-
[dependency-groups]
20-
dev = [
21-
"pytest>=8.4.0",
22-
"pytest-asyncio>=1.0.0",
23-
]
24-
2519
[project.urls]
2620
Homepage = "https://github.com/microsoft/teams.py/tree/main/packages/botbuilder/src/microsoft/teams/botbuilder"
2721

packages/botbuilder/src/microsoft/teams/botbuilder/botbuilder_plugin.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# pyright: reportMissingTypeStubs=false, reportUnknownMemberType=false
2-
31
"""
42
Copyright (c) Microsoft Corporation. All rights reserved.
53
Licensed under the MIT License.
@@ -8,7 +6,7 @@
86
import importlib.metadata
97
from logging import Logger
108
from types import SimpleNamespace
11-
from typing import Annotated, Any, Optional, Unpack, cast
9+
from typing import Annotated, Any, Optional, Unpack
1210

1311
from fastapi import HTTPException, Request, Response
1412
from microsoft.teams.api import Credentials
@@ -110,7 +108,7 @@ async def on_activity_request(self, request: Request, response: Response) -> Any
110108
try:
111109
# Parse activity data
112110
body = await request.json()
113-
activity_bf = cast(Activity, Activity().deserialize(body))
111+
activity_bf = Activity().deserialize(body)
114112

115113
# A POST request must contain an Activity
116114
if not activity_bf.type:

stubs/botbuilder/__init__.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Type stubs for botbuilder"""
2+
3+
# This file exists to make botbuilder a stub package

stubs/botbuilder/core/__init__.pyi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Type stubs for botbuilder.core"""
2+
3+
from botbuilder.schema import Activity
4+
from typing_extensions import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from botbuilder.integration.aiohttp import CloudAdapter
8+
9+
class TurnContext:
10+
"""Bot Framework Turn Context"""
11+
12+
activity: Activity
13+
14+
def __init__(
15+
self, adapter_or_context: CloudAdapter | TurnContext | None, activity: Activity | None = None
16+
) -> None: ...
17+
18+
class ActivityHandler:
19+
"""Bot Framework Activity Handler"""
20+
21+
def __init__(self) -> None: ...
22+
async def on_turn(self, turn_context: TurnContext) -> None: ...
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Type stubs for botbuilder.integration"""
2+
3+
# This file exists to make botbuilder.integration a stub package
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Type stubs for botbuilder.integration.aiohttp"""
2+
3+
from abc import ABC
4+
from typing import Any, Awaitable, Callable
5+
6+
from botbuilder.core import TurnContext
7+
from botbuilder.schema import Activity
8+
9+
class BotFrameworkAuthentication(ABC):
10+
"""Bot Framework Authentication"""
11+
12+
...
13+
14+
class ConfigurationBotFrameworkAuthentication(BotFrameworkAuthentication):
15+
"""Bot Framework Configuration Authentication"""
16+
17+
def __init__(self, configuration: Any) -> None: ...
18+
19+
class CloudAdapter:
20+
"""Bot Framework Cloud Adapter"""
21+
22+
def __init__(self, bot_framework_authentication: BotFrameworkAuthentication | None = None) -> None: ...
23+
async def process_activity(
24+
self,
25+
auth_header: str,
26+
activity: Activity,
27+
logic: Callable[[TurnContext], Awaitable[None]],
28+
) -> None: ...
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
"""Type stubs for botbuilder.schema"""
2+
3+
from __future__ import annotations
4+
5+
from typing import Any, List
6+
7+
# Forward declarations for referenced classes
8+
class ChannelAccount: ...
9+
class ConversationAccount: ...
10+
class MessageReaction: ...
11+
class SuggestedActions: ...
12+
class Attachment: ...
13+
class Entity: ...
14+
class ConversationReference: ...
15+
class TextHighlight: ...
16+
class SemanticAction: ...
17+
18+
class Activity:
19+
"""Bot Framework Activity"""
20+
21+
type: str | None = None
22+
id: str | None = None
23+
timestamp: str | None = None
24+
local_timestamp: str | None = None
25+
local_timezone: str | None = None
26+
service_url: str | None = None
27+
channel_id: str | None = None
28+
from_property: ChannelAccount | None = None
29+
conversation: ConversationAccount | None = None
30+
recipient: ChannelAccount | None = None
31+
text_format: str | None = None
32+
attachment_layout: str | None = None
33+
members_added: List[ChannelAccount] | None = None
34+
members_removed: List[ChannelAccount] | None = None
35+
reactions_added: List[MessageReaction] | None = None
36+
reactions_removed: List[MessageReaction] | None = None
37+
topic_name: str | None = None
38+
history_disclosed: bool | None = None
39+
locale: str | None = None
40+
text: str | None = None
41+
speak: str | None = None
42+
input_hint: str | None = None
43+
summary: str | None = None
44+
suggested_actions: SuggestedActions | None = None
45+
attachments: List[Attachment] | None = None
46+
entities: List[Entity] | None = None
47+
channel_data: Any | None = None
48+
action: str | None = None
49+
reply_to_id: str | None = None
50+
label: str | None = None
51+
value_type: str | None = None
52+
value: Any | None = None
53+
name: str | None = None
54+
relates_to: ConversationReference | None = None
55+
code: str | None = None
56+
expiration: str | None = None
57+
importance: str | None = None
58+
delivery_mode: str | None = None
59+
listen_for: List[str] | None = None
60+
text_highlights: List[TextHighlight] | None = None
61+
semantic_action: SemanticAction | None = None
62+
caller_id: str | None = None
63+
64+
def __init__(
65+
self,
66+
*,
67+
type: str | None = None,
68+
id: str | None = None,
69+
timestamp: str | None = None,
70+
local_timestamp: str | None = None,
71+
local_timezone: str | None = None,
72+
service_url: str | None = None,
73+
channel_id: str | None = None,
74+
from_property: ChannelAccount | None = None,
75+
conversation: ConversationAccount | None = None,
76+
recipient: ChannelAccount | None = None,
77+
text_format: str | None = None,
78+
attachment_layout: str | None = None,
79+
members_added: List[ChannelAccount] | None = None,
80+
members_removed: List[ChannelAccount] | None = None,
81+
reactions_added: List[MessageReaction] | None = None,
82+
reactions_removed: List[MessageReaction] | None = None,
83+
topic_name: str | None = None,
84+
history_disclosed: bool | None = None,
85+
locale: str | None = None,
86+
text: str | None = None,
87+
speak: str | None = None,
88+
input_hint: str | None = None,
89+
summary: str | None = None,
90+
suggested_actions: SuggestedActions | None = None,
91+
attachments: List[Attachment] | None = None,
92+
entities: List[Entity] | None = None,
93+
channel_data: Any | None = None,
94+
action: str | None = None,
95+
reply_to_id: str | None = None,
96+
label: str | None = None,
97+
value_type: str | None = None,
98+
value: Any | None = None,
99+
name: str | None = None,
100+
relates_to: ConversationReference | None = None,
101+
code: str | None = None,
102+
expiration: str | None = None,
103+
importance: str | None = None,
104+
delivery_mode: str | None = None,
105+
listen_for: List[str] | None = None,
106+
text_highlights: List[TextHighlight] | None = None,
107+
semantic_action: SemanticAction | None = None,
108+
caller_id: str | None = None,
109+
**kwargs: Any,
110+
) -> None: ...
111+
def deserialize(self, data: str | None = None, content_type: str | None = None) -> Activity: ...
112+
def serialize(self) -> dict[str, Any]: ...

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)