bito-code-review[bot] commented on code in PR #36933:
URL: https://github.com/apache/superset/pull/36933#discussion_r2927561664


##########
superset/mcp_service/embedded_chart/tool/get_embeddable_chart.py:
##########
@@ -0,0 +1,286 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+MCP tool: get_embeddable_chart
+
+Creates an embeddable chart iframe with guest token authentication.
+This enables AI agents to generate charts that can be displayed in
+external applications via iframe.
+"""
+
+import logging
+from datetime import datetime, timedelta, timezone
+
+from fastmcp import Context
+from flask import g
+from superset_core.mcp.decorators import tool
+
+from superset.commands.exceptions import CommandException
+from superset.mcp_service.chart.chart_utils import (
+    map_config_to_form_data,
+    resolve_dataset,
+)
+from superset.mcp_service.embedded_chart.schemas import (
+    GetEmbeddableChartRequest,
+    GetEmbeddableChartResponse,
+)
+from superset.mcp_service.utils.schema_utils import parse_request
+from superset.mcp_service.utils.url_utils import get_superset_base_url
+from superset.security.guest_token import (
+    GuestTokenResource,

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Type-only imports should be in TYPE_CHECKING</b></div>
   <div id="fix">
   
   Move `GuestTokenResource`, `GuestTokenRlsRule`, and `GuestTokenUser` imports 
(lines 44-46) into a `TYPE_CHECKING` block to avoid runtime circular imports. 
These are used only for type annotations.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
     from datetime import datetime, timedelta, timezone
    
    +from typing import TYPE_CHECKING
     from fastmcp import Context
     from flask import g
     from superset_core.mcp.decorators import tool
    @@ -41,9 +42,12 @@
     from superset.mcp_service.utils.schema_utils import parse_request
     from superset.mcp_service.utils.url_utils import get_superset_base_url
    -from superset.security.guest_token import (
    -    GuestTokenResource,
    -    GuestTokenRlsRule,
    -    GuestTokenUser,
    -)
    +from superset.security.guest_token import GuestTokenResourceType
    +
    +if TYPE_CHECKING:
    +    from superset.security.guest_token import (
    +        GuestTokenResource,
    +        GuestTokenRlsRule,
    +        GuestTokenUser,
    +    )
   ```
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #d07566</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to