From 6df6bba62ba26ac0917472efc3a30240d98eeda6 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Tue, 14 Dec 2021 13:52:15 +0900 Subject: [PATCH] version 1.11.0 --- .../slack_bolt/adapter/falcon/resource.html | 2 +- .../slack_bolt/adapter/flask/handler.html | 6 ++ .../adapter/sanic/async_handler.html | 2 +- .../adapter/starlette/async_handler.html | 70 ++++++++++++----- .../slack_bolt/adapter/starlette/handler.html | 76 ++++++++++++++----- .../slack_bolt/adapter/tornado/handler.html | 2 +- .../slack_bolt/context/async_context.html | 66 ++++++++++++++++ .../slack_bolt/context/base_context.html | 55 +++++++++++++- docs/api-docs/slack_bolt/context/context.html | 69 +++++++++++++++++ .../slack_bolt/listener/asyncio_runner.html | 4 +- .../slack_bolt/listener/thread_runner.html | 4 +- .../slack_bolt/request/async_request.html | 45 ++++++++++- docs/api-docs/slack_bolt/request/request.html | 45 ++++++++++- docs/api-docs/slack_bolt/version.html | 2 +- slack_bolt/version.py | 2 +- 15 files changed, 396 insertions(+), 54 deletions(-) diff --git a/docs/api-docs/slack_bolt/adapter/falcon/resource.html b/docs/api-docs/slack_bolt/adapter/falcon/resource.html index ae29f18b2..7a59a9c63 100644 --- a/docs/api-docs/slack_bolt/adapter/falcon/resource.html +++ b/docs/api-docs/slack_bolt/adapter/falcon/resource.html @@ -26,7 +26,7 @@

Module slack_bolt.adapter.falcon.resource

Expand source code -
from datetime import datetime
+
from datetime import datetime  # type: ignore
 from http import HTTPStatus
 
 from falcon import Request, Response
diff --git a/docs/api-docs/slack_bolt/adapter/flask/handler.html b/docs/api-docs/slack_bolt/adapter/flask/handler.html
index 247dbba15..e69438873 100644
--- a/docs/api-docs/slack_bolt/adapter/flask/handler.html
+++ b/docs/api-docs/slack_bolt/adapter/flask/handler.html
@@ -45,6 +45,9 @@ 

Module slack_bolt.adapter.flask.handler

def to_flask_response(bolt_resp: BoltResponse) -> Response: resp: Response = make_response(bolt_resp.body, bolt_resp.status) for k, values in bolt_resp.headers.items(): + if k.lower() == "content-type" and resp.headers.get("content-type") is not None: + # Remove the one set by Flask + resp.headers.pop("content-type") for v in values: resp.headers.add_header(k, v) return resp @@ -107,6 +110,9 @@

Functions

def to_flask_response(bolt_resp: BoltResponse) -> Response:
     resp: Response = make_response(bolt_resp.body, bolt_resp.status)
     for k, values in bolt_resp.headers.items():
+        if k.lower() == "content-type" and resp.headers.get("content-type") is not None:
+            # Remove the one set by Flask
+            resp.headers.pop("content-type")
         for v in values:
             resp.headers.add_header(k, v)
     return resp
diff --git a/docs/api-docs/slack_bolt/adapter/sanic/async_handler.html b/docs/api-docs/slack_bolt/adapter/sanic/async_handler.html index 1577a05f6..ff0c7d1c3 100644 --- a/docs/api-docs/slack_bolt/adapter/sanic/async_handler.html +++ b/docs/api-docs/slack_bolt/adapter/sanic/async_handler.html @@ -26,7 +26,7 @@

Module slack_bolt.adapter.sanic.async_handler

Expand source code -
from datetime import datetime
+
from datetime import datetime  # type: ignore
 
 from sanic.request import Request
 from sanic.response import HTTPResponse
diff --git a/docs/api-docs/slack_bolt/adapter/starlette/async_handler.html b/docs/api-docs/slack_bolt/adapter/starlette/async_handler.html
index 5f1ecf75a..82c371af7 100644
--- a/docs/api-docs/slack_bolt/adapter/starlette/async_handler.html
+++ b/docs/api-docs/slack_bolt/adapter/starlette/async_handler.html
@@ -26,7 +26,9 @@ 

Module slack_bolt.adapter.starlette.async_handler Expand source code -
from starlette.requests import Request
+
from typing import Dict, Any, Optional
+
+from starlette.requests import Request
 from starlette.responses import Response
 
 from slack_bolt import BoltResponse
@@ -34,12 +36,20 @@ 

Module slack_bolt.adapter.starlette.async_handler from slack_bolt.oauth.async_oauth_flow import AsyncOAuthFlow -def to_async_bolt_request(req: Request, body: bytes) -> AsyncBoltRequest: - return AsyncBoltRequest( +def to_async_bolt_request( + req: Request, + body: bytes, + addition_context_properties: Optional[Dict[str, Any]] = None, +) -> AsyncBoltRequest: + request = AsyncBoltRequest( body=body.decode("utf-8"), query=req.query_params, headers=req.headers, ) + if addition_context_properties is not None: + for k, v in addition_context_properties.items(): + request.context[k] = v + return request def to_starlette_response(bolt_resp: BoltResponse) -> Response: @@ -67,23 +77,27 @@

Module slack_bolt.adapter.starlette.async_handler def __init__(self, app: AsyncApp): # type: ignore self.app = app - async def handle(self, req: Request) -> Response: + async def handle( + self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None + ) -> Response: body = await req.body() if req.method == "GET": if self.app.oauth_flow is not None: oauth_flow: AsyncOAuthFlow = self.app.oauth_flow if req.url.path == oauth_flow.install_path: bolt_resp = await oauth_flow.handle_installation( - to_async_bolt_request(req, body) + to_async_bolt_request(req, body, addition_context_properties) ) return to_starlette_response(bolt_resp) elif req.url.path == oauth_flow.redirect_uri_path: bolt_resp = await oauth_flow.handle_callback( - to_async_bolt_request(req, body) + to_async_bolt_request(req, body, addition_context_properties) ) return to_starlette_response(bolt_resp) elif req.method == "POST": - bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body)) + bolt_resp = await self.app.async_dispatch( + to_async_bolt_request(req, body, addition_context_properties) + ) return to_starlette_response(bolt_resp) return Response( @@ -100,7 +114,7 @@

Module slack_bolt.adapter.starlette.async_handler

Functions

-def to_async_bolt_request(req: starlette.requests.Request, body: bytes) ‑> AsyncBoltRequest +def to_async_bolt_request(req: starlette.requests.Request, body: bytes, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> AsyncBoltRequest
@@ -108,12 +122,20 @@

Functions

Expand source code -
def to_async_bolt_request(req: Request, body: bytes) -> AsyncBoltRequest:
-    return AsyncBoltRequest(
+
def to_async_bolt_request(
+    req: Request,
+    body: bytes,
+    addition_context_properties: Optional[Dict[str, Any]] = None,
+) -> AsyncBoltRequest:
+    request = AsyncBoltRequest(
         body=body.decode("utf-8"),
         query=req.query_params,
         headers=req.headers,
-    )
+ ) + if addition_context_properties is not None: + for k, v in addition_context_properties.items(): + request.context[k] = v + return request
@@ -165,23 +187,27 @@

Classes

def __init__(self, app: AsyncApp): # type: ignore self.app = app - async def handle(self, req: Request) -> Response: + async def handle( + self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None + ) -> Response: body = await req.body() if req.method == "GET": if self.app.oauth_flow is not None: oauth_flow: AsyncOAuthFlow = self.app.oauth_flow if req.url.path == oauth_flow.install_path: bolt_resp = await oauth_flow.handle_installation( - to_async_bolt_request(req, body) + to_async_bolt_request(req, body, addition_context_properties) ) return to_starlette_response(bolt_resp) elif req.url.path == oauth_flow.redirect_uri_path: bolt_resp = await oauth_flow.handle_callback( - to_async_bolt_request(req, body) + to_async_bolt_request(req, body, addition_context_properties) ) return to_starlette_response(bolt_resp) elif req.method == "POST": - bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body)) + bolt_resp = await self.app.async_dispatch( + to_async_bolt_request(req, body, addition_context_properties) + ) return to_starlette_response(bolt_resp) return Response( @@ -192,7 +218,7 @@

Classes

Methods

-async def handle(self, req: starlette.requests.Request) ‑> starlette.responses.Response +async def handle(self, req: starlette.requests.Request, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> starlette.responses.Response
@@ -200,23 +226,27 @@

Methods

Expand source code -
async def handle(self, req: Request) -> Response:
+
async def handle(
+    self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
+) -> Response:
     body = await req.body()
     if req.method == "GET":
         if self.app.oauth_flow is not None:
             oauth_flow: AsyncOAuthFlow = self.app.oauth_flow
             if req.url.path == oauth_flow.install_path:
                 bolt_resp = await oauth_flow.handle_installation(
-                    to_async_bolt_request(req, body)
+                    to_async_bolt_request(req, body, addition_context_properties)
                 )
                 return to_starlette_response(bolt_resp)
             elif req.url.path == oauth_flow.redirect_uri_path:
                 bolt_resp = await oauth_flow.handle_callback(
-                    to_async_bolt_request(req, body)
+                    to_async_bolt_request(req, body, addition_context_properties)
                 )
                 return to_starlette_response(bolt_resp)
     elif req.method == "POST":
-        bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body))
+        bolt_resp = await self.app.async_dispatch(
+            to_async_bolt_request(req, body, addition_context_properties)
+        )
         return to_starlette_response(bolt_resp)
 
     return Response(
diff --git a/docs/api-docs/slack_bolt/adapter/starlette/handler.html b/docs/api-docs/slack_bolt/adapter/starlette/handler.html
index cb77cba85..d605b274a 100644
--- a/docs/api-docs/slack_bolt/adapter/starlette/handler.html
+++ b/docs/api-docs/slack_bolt/adapter/starlette/handler.html
@@ -26,19 +26,29 @@ 

Module slack_bolt.adapter.starlette.handler

Expand source code -
from starlette.requests import Request
+
from typing import Dict, Any, Optional
+
+from starlette.requests import Request
 from starlette.responses import Response
 
 from slack_bolt import BoltRequest, App, BoltResponse
 from slack_bolt.oauth import OAuthFlow
 
 
-def to_bolt_request(req: Request, body: bytes) -> BoltRequest:
-    return BoltRequest(
+def to_bolt_request(
+    req: Request,
+    body: bytes,
+    addition_context_properties: Optional[Dict[str, Any]] = None,
+) -> BoltRequest:
+    request = BoltRequest(
         body=body.decode("utf-8"),
         query=req.query_params,
         headers=req.headers,
     )
+    if addition_context_properties is not None:
+        for k, v in addition_context_properties.items():
+            request.context[k] = v
+    return request
 
 
 def to_starlette_response(bolt_resp: BoltResponse) -> Response:
@@ -66,21 +76,27 @@ 

Module slack_bolt.adapter.starlette.handler

def __init__(self, app: App): # type: ignore self.app = app - async def handle(self, req: Request) -> Response: + async def handle( + self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None + ) -> Response: body = await req.body() if req.method == "GET": if self.app.oauth_flow is not None: oauth_flow: OAuthFlow = self.app.oauth_flow if req.url.path == oauth_flow.install_path: bolt_resp = oauth_flow.handle_installation( - to_bolt_request(req, body) + to_bolt_request(req, body, addition_context_properties) ) return to_starlette_response(bolt_resp) elif req.url.path == oauth_flow.redirect_uri_path: - bolt_resp = oauth_flow.handle_callback(to_bolt_request(req, body)) + bolt_resp = oauth_flow.handle_callback( + to_bolt_request(req, body, addition_context_properties) + ) return to_starlette_response(bolt_resp) elif req.method == "POST": - bolt_resp = self.app.dispatch(to_bolt_request(req, body)) + bolt_resp = self.app.dispatch( + to_bolt_request(req, body, addition_context_properties) + ) return to_starlette_response(bolt_resp) return Response( @@ -97,7 +113,7 @@

Module slack_bolt.adapter.starlette.handler

Functions

-def to_bolt_request(req: starlette.requests.Request, body: bytes) ‑> BoltRequest +def to_bolt_request(req: starlette.requests.Request, body: bytes, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> BoltRequest
@@ -105,12 +121,20 @@

Functions

Expand source code -
def to_bolt_request(req: Request, body: bytes) -> BoltRequest:
-    return BoltRequest(
+
def to_bolt_request(
+    req: Request,
+    body: bytes,
+    addition_context_properties: Optional[Dict[str, Any]] = None,
+) -> BoltRequest:
+    request = BoltRequest(
         body=body.decode("utf-8"),
         query=req.query_params,
         headers=req.headers,
-    )
+ ) + if addition_context_properties is not None: + for k, v in addition_context_properties.items(): + request.context[k] = v + return request
@@ -162,21 +186,27 @@

Classes

def __init__(self, app: App): # type: ignore self.app = app - async def handle(self, req: Request) -> Response: + async def handle( + self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None + ) -> Response: body = await req.body() if req.method == "GET": if self.app.oauth_flow is not None: oauth_flow: OAuthFlow = self.app.oauth_flow if req.url.path == oauth_flow.install_path: bolt_resp = oauth_flow.handle_installation( - to_bolt_request(req, body) + to_bolt_request(req, body, addition_context_properties) ) return to_starlette_response(bolt_resp) elif req.url.path == oauth_flow.redirect_uri_path: - bolt_resp = oauth_flow.handle_callback(to_bolt_request(req, body)) + bolt_resp = oauth_flow.handle_callback( + to_bolt_request(req, body, addition_context_properties) + ) return to_starlette_response(bolt_resp) elif req.method == "POST": - bolt_resp = self.app.dispatch(to_bolt_request(req, body)) + bolt_resp = self.app.dispatch( + to_bolt_request(req, body, addition_context_properties) + ) return to_starlette_response(bolt_resp) return Response( @@ -187,7 +217,7 @@

Classes

Methods

-async def handle(self, req: starlette.requests.Request) ‑> starlette.responses.Response +async def handle(self, req: starlette.requests.Request, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> starlette.responses.Response
@@ -195,21 +225,27 @@

Methods

Expand source code -
async def handle(self, req: Request) -> Response:
+
async def handle(
+    self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
+) -> Response:
     body = await req.body()
     if req.method == "GET":
         if self.app.oauth_flow is not None:
             oauth_flow: OAuthFlow = self.app.oauth_flow
             if req.url.path == oauth_flow.install_path:
                 bolt_resp = oauth_flow.handle_installation(
-                    to_bolt_request(req, body)
+                    to_bolt_request(req, body, addition_context_properties)
                 )
                 return to_starlette_response(bolt_resp)
             elif req.url.path == oauth_flow.redirect_uri_path:
-                bolt_resp = oauth_flow.handle_callback(to_bolt_request(req, body))
+                bolt_resp = oauth_flow.handle_callback(
+                    to_bolt_request(req, body, addition_context_properties)
+                )
                 return to_starlette_response(bolt_resp)
     elif req.method == "POST":
-        bolt_resp = self.app.dispatch(to_bolt_request(req, body))
+        bolt_resp = self.app.dispatch(
+            to_bolt_request(req, body, addition_context_properties)
+        )
         return to_starlette_response(bolt_resp)
 
     return Response(
diff --git a/docs/api-docs/slack_bolt/adapter/tornado/handler.html b/docs/api-docs/slack_bolt/adapter/tornado/handler.html
index 3c1ca74b2..c41a9f48e 100644
--- a/docs/api-docs/slack_bolt/adapter/tornado/handler.html
+++ b/docs/api-docs/slack_bolt/adapter/tornado/handler.html
@@ -26,7 +26,7 @@ 

Module slack_bolt.adapter.tornado.handler

Expand source code -
from datetime import datetime
+
from datetime import datetime  # type: ignore
 
 from tornado.httputil import HTTPServerRequest
 from tornado.web import RequestHandler
diff --git a/docs/api-docs/slack_bolt/context/async_context.html b/docs/api-docs/slack_bolt/context/async_context.html
index a417e91b5..f20c1d0f5 100644
--- a/docs/api-docs/slack_bolt/context/async_context.html
+++ b/docs/api-docs/slack_bolt/context/async_context.html
@@ -34,11 +34,29 @@ 

Module slack_bolt.context.async_context

from slack_bolt.context.base_context import BaseContext from slack_bolt.context.respond.async_respond import AsyncRespond from slack_bolt.context.say.async_say import AsyncSay +from slack_bolt.util.utils import create_copy class AsyncBoltContext(BaseContext): """Context object associated with a request from Slack.""" + def to_copyable(self) -> "AsyncBoltContext": + new_dict = {} + for prop_name, prop_value in self.items(): + if prop_name in self.standard_property_names: + # all the standard properties are copiable + new_dict[prop_name] = prop_value + else: + try: + copied_value = create_copy(prop_value) + new_dict[prop_name] = copied_value + except TypeError as te: + self.logger.debug( + f"Skipped settings '{prop_name}' to a copied request for lazy listeners " + f"as it's not possible to make a deep copy (error: {te})" + ) + return AsyncBoltContext(new_dict) + @property def client(self) -> Optional[AsyncWebClient]: """The `AsyncWebClient` instance available for this request. @@ -152,6 +170,23 @@

Classes

class AsyncBoltContext(BaseContext):
     """Context object associated with a request from Slack."""
 
+    def to_copyable(self) -> "AsyncBoltContext":
+        new_dict = {}
+        for prop_name, prop_value in self.items():
+            if prop_name in self.standard_property_names:
+                # all the standard properties are copiable
+                new_dict[prop_name] = prop_value
+            else:
+                try:
+                    copied_value = create_copy(prop_value)
+                    new_dict[prop_name] = copied_value
+                except TypeError as te:
+                    self.logger.debug(
+                        f"Skipped settings '{prop_name}' to a copied request for lazy listeners "
+                        f"as it's not possible to make a deep copy (error: {te})"
+                    )
+        return AsyncBoltContext(new_dict)
+
     @property
     def client(self) -> Optional[AsyncWebClient]:
         """The `AsyncWebClient` instance available for this request.
@@ -426,6 +461,36 @@ 

Returns

+

Methods

+
+
+def to_copyable(self) ‑> AsyncBoltContext +
+
+
+
+ +Expand source code + +
def to_copyable(self) -> "AsyncBoltContext":
+    new_dict = {}
+    for prop_name, prop_value in self.items():
+        if prop_name in self.standard_property_names:
+            # all the standard properties are copiable
+            new_dict[prop_name] = prop_value
+        else:
+            try:
+                copied_value = create_copy(prop_value)
+                new_dict[prop_name] = copied_value
+            except TypeError as te:
+                self.logger.debug(
+                    f"Skipped settings '{prop_name}' to a copied request for lazy listeners "
+                    f"as it's not possible to make a deep copy (error: {te})"
+                )
+    return AsyncBoltContext(new_dict)
+
+
+

Inherited members

diff --git a/docs/api-docs/slack_bolt/context/base_context.html b/docs/api-docs/slack_bolt/context/base_context.html index d694b9e20..fcf7bbb85 100644 --- a/docs/api-docs/slack_bolt/context/base_context.html +++ b/docs/api-docs/slack_bolt/context/base_context.html @@ -26,7 +26,10 @@

Module slack_bolt.context.base_context

Expand source code -
from logging import Logger
+
# pytype: skip-file
+# Note: Since 2021.12.8, the pytype code analyzer does not properly work for this file
+
+from logging import Logger
 from typing import Optional, Tuple
 
 from slack_bolt.authorization import AuthorizeResult
@@ -35,6 +38,27 @@ 

Module slack_bolt.context.base_context

class BaseContext(dict): """Context object associated with a request from Slack.""" + standard_property_names = [ + "logger", + "token", + "enterprise_id", + "is_enterprise_install", + "team_id", + "user_id", + "channel_id", + "response_url", + "matches", + "authorize_result", + "bot_token", + "bot_id", + "bot_user_id", + "user_token", + "client", + "ack", + "say", + "respond", + ] + @property def logger(self) -> Logger: """The properly configured logger that is available for middleware/listeners.""" @@ -143,6 +167,27 @@

Classes

class BaseContext(dict):
     """Context object associated with a request from Slack."""
 
+    standard_property_names = [
+        "logger",
+        "token",
+        "enterprise_id",
+        "is_enterprise_install",
+        "team_id",
+        "user_id",
+        "channel_id",
+        "response_url",
+        "matches",
+        "authorize_result",
+        "bot_token",
+        "bot_id",
+        "bot_user_id",
+        "user_token",
+        "client",
+        "ack",
+        "say",
+        "respond",
+    ]
+
     @property
     def logger(self) -> Logger:
         """The properly configured logger that is available for middleware/listeners."""
@@ -237,6 +282,13 @@ 

Subclasses

  • AsyncBoltContext
  • BoltContext
  • +

    Class variables

    +
    +
    var standard_property_names
    +
    +
    +
    +

    Instance variables

    var authorize_result : Optional[AuthorizeResult]
    @@ -479,6 +531,7 @@

    matches
  • response_url
  • set_authorize_result
  • +
  • standard_property_names
  • team_id
  • token
  • user_id
  • diff --git a/docs/api-docs/slack_bolt/context/context.html b/docs/api-docs/slack_bolt/context/context.html index 9cbda05ba..af4ad5f26 100644 --- a/docs/api-docs/slack_bolt/context/context.html +++ b/docs/api-docs/slack_bolt/context/context.html @@ -35,11 +35,30 @@

    Module slack_bolt.context.context

    from slack_bolt.context.base_context import BaseContext from slack_bolt.context.respond import Respond from slack_bolt.context.say import Say +from slack_bolt.util.utils import create_copy class BoltContext(BaseContext): """Context object associated with a request from Slack.""" + def to_copyable(self) -> "BoltContext": + new_dict = {} + for prop_name, prop_value in self.items(): + if prop_name in self.standard_property_names: + # all the standard properties are copiable + new_dict[prop_name] = prop_value + else: + try: + copied_value = create_copy(prop_value) + new_dict[prop_name] = copied_value + except TypeError as te: + self.logger.warning( + f"Skipped setting '{prop_name}' to a copied request for lazy listeners " + "due to a deep-copy creation error. Consider passing the value not as part of context object " + f"(error: {te})" + ) + return BoltContext(new_dict) + @property def client(self) -> Optional[WebClient]: """The `WebClient` instance available for this request. @@ -153,6 +172,24 @@

    Classes

    class BoltContext(BaseContext):
         """Context object associated with a request from Slack."""
     
    +    def to_copyable(self) -> "BoltContext":
    +        new_dict = {}
    +        for prop_name, prop_value in self.items():
    +            if prop_name in self.standard_property_names:
    +                # all the standard properties are copiable
    +                new_dict[prop_name] = prop_value
    +            else:
    +                try:
    +                    copied_value = create_copy(prop_value)
    +                    new_dict[prop_name] = copied_value
    +                except TypeError as te:
    +                    self.logger.warning(
    +                        f"Skipped setting '{prop_name}' to a copied request for lazy listeners "
    +                        "due to a deep-copy creation error. Consider passing the value not as part of context object "
    +                        f"(error: {te})"
    +                    )
    +        return BoltContext(new_dict)
    +
         @property
         def client(self) -> Optional[WebClient]:
             """The `WebClient` instance available for this request.
    @@ -427,6 +464,37 @@ 

    Returns

    +

    Methods

    +
    +
    +def to_copyable(self) ‑> BoltContext +
    +
    +
    +
    + +Expand source code + +
    def to_copyable(self) -> "BoltContext":
    +    new_dict = {}
    +    for prop_name, prop_value in self.items():
    +        if prop_name in self.standard_property_names:
    +            # all the standard properties are copiable
    +            new_dict[prop_name] = prop_value
    +        else:
    +            try:
    +                copied_value = create_copy(prop_value)
    +                new_dict[prop_name] = copied_value
    +            except TypeError as te:
    +                self.logger.warning(
    +                    f"Skipped setting '{prop_name}' to a copied request for lazy listeners "
    +                    "due to a deep-copy creation error. Consider passing the value not as part of context object "
    +                    f"(error: {te})"
    +                )
    +    return BoltContext(new_dict)
    +
    +
    +

    Inherited members

    diff --git a/docs/api-docs/slack_bolt/listener/asyncio_runner.html b/docs/api-docs/slack_bolt/listener/asyncio_runner.html index 7dc21f332..8f0a822aa 100644 --- a/docs/api-docs/slack_bolt/listener/asyncio_runner.html +++ b/docs/api-docs/slack_bolt/listener/asyncio_runner.html @@ -226,7 +226,7 @@

    Module slack_bolt.listener.asyncio_runner

    def _build_lazy_request( request: AsyncBoltRequest, lazy_func_name: str ) -> AsyncBoltRequest: - copied_request = create_copy(request) + copied_request = create_copy(request.to_copyable()) copied_request.method = "NONE" copied_request.lazy_only = True copied_request.lazy_function_name = lazy_func_name @@ -432,7 +432,7 @@

    Classes

    def _build_lazy_request( request: AsyncBoltRequest, lazy_func_name: str ) -> AsyncBoltRequest: - copied_request = create_copy(request) + copied_request = create_copy(request.to_copyable()) copied_request.method = "NONE" copied_request.lazy_only = True copied_request.lazy_function_name = lazy_func_name diff --git a/docs/api-docs/slack_bolt/listener/thread_runner.html b/docs/api-docs/slack_bolt/listener/thread_runner.html index 43c7da783..ce6a74e17 100644 --- a/docs/api-docs/slack_bolt/listener/thread_runner.html +++ b/docs/api-docs/slack_bolt/listener/thread_runner.html @@ -223,7 +223,7 @@

    Module slack_bolt.listener.thread_runner

    @staticmethod def _build_lazy_request(request: BoltRequest, lazy_func_name: str) -> BoltRequest: - copied_request = create_copy(request) + copied_request = create_copy(request.to_copyable()) copied_request.method = "NONE" copied_request.lazy_only = True copied_request.lazy_function_name = lazy_func_name @@ -432,7 +432,7 @@

    Classes

    @staticmethod def _build_lazy_request(request: BoltRequest, lazy_func_name: str) -> BoltRequest: - copied_request = create_copy(request) + copied_request = create_copy(request.to_copyable()) copied_request.method = "NONE" copied_request.lazy_only = True copied_request.lazy_function_name = lazy_func_name diff --git a/docs/api-docs/slack_bolt/request/async_request.html b/docs/api-docs/slack_bolt/request/async_request.html index 2106594cd..f415d8243 100644 --- a/docs/api-docs/slack_bolt/request/async_request.html +++ b/docs/api-docs/slack_bolt/request/async_request.html @@ -102,7 +102,16 @@

    Module slack_bolt.request.async_request

    self.lazy_function_name = self.headers.get( "x-slack-bolt-lazy-function-name", [None] )[0] - self.mode = mode
    + self.mode = mode + + def to_copyable(self) -> "AsyncBoltRequest": + return AsyncBoltRequest( + body=self.raw_body, + query=self.query, + headers=self.headers, + context=self.context.to_copyable(), + mode=self.mode, + )
    @@ -199,7 +208,16 @@

    Args

    self.lazy_function_name = self.headers.get( "x-slack-bolt-lazy-function-name", [None] )[0] - self.mode = mode

    + self.mode = mode + + def to_copyable(self) -> "AsyncBoltRequest": + return AsyncBoltRequest( + body=self.raw_body, + query=self.query, + headers=self.headers, + context=self.context.to_copyable(), + mode=self.mode, + )

    Class variables

    @@ -240,6 +258,28 @@

    Class variables

    +

    Methods

    +
    +
    +def to_copyable(self) ‑> AsyncBoltRequest +
    +
    +
    +
    + +Expand source code + +
    def to_copyable(self) -> "AsyncBoltRequest":
    +    return AsyncBoltRequest(
    +        body=self.raw_body,
    +        query=self.query,
    +        headers=self.headers,
    +        context=self.context.to_copyable(),
    +        mode=self.mode,
    +    )
    +
    +
    +
    @@ -269,6 +309,7 @@

    mode
  • query
  • raw_body
  • +
  • to_copyable
  • diff --git a/docs/api-docs/slack_bolt/request/request.html b/docs/api-docs/slack_bolt/request/request.html index deec3891a..f8fec2d0d 100644 --- a/docs/api-docs/slack_bolt/request/request.html +++ b/docs/api-docs/slack_bolt/request/request.html @@ -99,7 +99,16 @@

    Module slack_bolt.request.request

    self.lazy_function_name = self.headers.get( "x-slack-bolt-lazy-function-name", [None] )[0] - self.mode = mode
    + self.mode = mode + + def to_copyable(self) -> "BoltRequest": + return BoltRequest( + body=self.raw_body, + query=self.query, + headers=self.headers, + context=self.context.to_copyable(), + mode=self.mode, + )
    @@ -193,7 +202,16 @@

    Args

    self.lazy_function_name = self.headers.get( "x-slack-bolt-lazy-function-name", [None] )[0] - self.mode = mode + self.mode = mode + + def to_copyable(self) -> "BoltRequest": + return BoltRequest( + body=self.raw_body, + query=self.query, + headers=self.headers, + context=self.context.to_copyable(), + mode=self.mode, + )

    Class variables

    @@ -234,6 +252,28 @@

    Class variables

    +

    Methods

    +
    +
    +def to_copyable(self) ‑> BoltRequest +
    +
    +
    +
    + +Expand source code + +
    def to_copyable(self) -> "BoltRequest":
    +    return BoltRequest(
    +        body=self.raw_body,
    +        query=self.query,
    +        headers=self.headers,
    +        context=self.context.to_copyable(),
    +        mode=self.mode,
    +    )
    +
    +
    +
    @@ -263,6 +303,7 @@

    mode
  • query
  • raw_body
  • +
  • to_copyable
  • diff --git a/docs/api-docs/slack_bolt/version.html b/docs/api-docs/slack_bolt/version.html index 816a33b11..860e5fc2e 100644 --- a/docs/api-docs/slack_bolt/version.html +++ b/docs/api-docs/slack_bolt/version.html @@ -28,7 +28,7 @@

    Module slack_bolt.version

    Expand source code
    """Check the latest version at https://pypi.org/project/slack-bolt/"""
    -__version__ = "1.10.0"
    +__version__ = "1.11.0"
    diff --git a/slack_bolt/version.py b/slack_bolt/version.py index 0872b5816..63a520b24 100644 --- a/slack_bolt/version.py +++ b/slack_bolt/version.py @@ -1,2 +1,2 @@ """Check the latest version at https://pypi.org/project/slack-bolt/""" -__version__ = "1.10.0" +__version__ = "1.11.0"