codeant-ai-for-open-source[bot] commented on code in PR #41497: URL: https://github.com/apache/superset/pull/41497#discussion_r3532823480
########## superset/mcp_service/theme/tool/create_theme.py: ########## @@ -0,0 +1,151 @@ +# 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. + +""" +Create theme FastMCP tool + +Creates a reusable Superset theme from an antd design-token configuration. +The supplied json_data is sanitized and validated with the same routine the +REST API uses before the theme is persisted via ThemeDAO. +""" + +import logging +from typing import Any + +from fastmcp import Context +from marshmallow import ValidationError +from sqlalchemy.exc import SQLAlchemyError +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import db, event_logger +from superset.mcp_service.theme.schemas import CreateThemeRequest, CreateThemeResponse +from superset.themes.schemas import _sanitize_and_validate_theme_config +from superset.utils import json + +logger = logging.getLogger(__name__) + + +@tool( + tags=["mutate"], + class_permission_name="Theme", + method_permission_name="write", + annotations=ToolAnnotations( + title="Create theme", + readOnlyHint=False, + destructiveHint=False, + ), +) +async def create_theme( + request: CreateThemeRequest, ctx: Context +) -> CreateThemeResponse: + """Create a reusable theme from antd design tokens. + + Accepts a theme name and an antd design-token configuration (json_data), + supplied either as a JSON object or a JSON string. The configuration is + sanitized and validated the same way the REST API validates themes before + the theme is persisted. + + Required fields: + - theme_name: Human-readable name for the theme + - json_data: The antd design-token configuration (dict or JSON string) + + Example: + ```json + { + "theme_name": "Corporate Blue", + "json_data": {"token": {"colorPrimary": "#1d4ed8"}} + } + ``` + + Returns CreateThemeResponse with the new theme's id and uuid on success, + or an error response (error_type="ValidationError") if the configuration + is invalid. + """ + await ctx.info("Creating theme: theme_name=%s" % (request.theme_name,)) + + # Parse json_data into a dict (accept dict or JSON string) + config_dict: dict[str, Any] + if isinstance(request.json_data, str): + try: + parsed = json.loads(request.json_data) Review Comment: **Suggestion:** Add an explicit type annotation for `parsed` when loading JSON so this new local variable is typed. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The new Python file introduces a local variable `parsed` without an explicit type annotation, which matches the rule requiring type hints on relevant variables that can be annotated. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6093e3b90aa540ff8e044fb9bcd41817&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6093e3b90aa540ff8e044fb9bcd41817&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/create_theme.py **Line:** 84:84 **Comment:** *Custom Rule: Add an explicit type annotation for `parsed` when loading JSON so this new local variable is typed. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=ecae150ef92f03c74cc4fecc499fb13ed80294473b2f7272c9f56c26d3178eff&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=ecae150ef92f03c74cc4fecc499fb13ed80294473b2f7272c9f56c26d3178eff&reaction=dislike'>👎</a> ########## superset/mcp_service/theme/tool/get_theme_info.py: ########## @@ -0,0 +1,111 @@ +# 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. + +""" +Get theme info FastMCP tool + +This module contains the FastMCP tool for getting detailed information +about a specific theme by numeric ID or UUID. +""" + +import logging +from datetime import datetime, timezone + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import event_logger +from superset.mcp_service.mcp_core import ModelGetInfoCore +from superset.mcp_service.theme.schemas import ( + GetThemeInfoRequest, + serialize_theme_object, + ThemeError, + ThemeInfo, +) + +logger = logging.getLogger(__name__) Review Comment: **Suggestion:** Add an explicit type annotation for the module-level logger variable to satisfy the type-hint requirement for annotatable variables. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The new module-level `logger` variable is an annotatable Python variable, and it is introduced without a type hint. This matches the rule requiring type hints for relevant variables in new or modified Python code. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=2ac9df8ae5c444f69edd2dc002738ad2&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=2ac9df8ae5c444f69edd2dc002738ad2&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/get_theme_info.py **Line:** 40:40 **Comment:** *Custom Rule: Add an explicit type annotation for the module-level logger variable to satisfy the type-hint requirement for annotatable variables. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=82e0c89f11d1165e4bc30f87908b80bcade9fdd295565ecc0b00c8b26259a74a&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=82e0c89f11d1165e4bc30f87908b80bcade9fdd295565ecc0b00c8b26259a74a&reaction=dislike'>👎</a> ########## superset/mcp_service/theme/tool/create_theme.py: ########## @@ -0,0 +1,151 @@ +# 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. + +""" +Create theme FastMCP tool + +Creates a reusable Superset theme from an antd design-token configuration. +The supplied json_data is sanitized and validated with the same routine the +REST API uses before the theme is persisted via ThemeDAO. +""" + +import logging +from typing import Any + +from fastmcp import Context +from marshmallow import ValidationError +from sqlalchemy.exc import SQLAlchemyError +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import db, event_logger +from superset.mcp_service.theme.schemas import CreateThemeRequest, CreateThemeResponse +from superset.themes.schemas import _sanitize_and_validate_theme_config +from superset.utils import json + +logger = logging.getLogger(__name__) + + +@tool( + tags=["mutate"], + class_permission_name="Theme", + method_permission_name="write", + annotations=ToolAnnotations( + title="Create theme", + readOnlyHint=False, + destructiveHint=False, + ), +) +async def create_theme( + request: CreateThemeRequest, ctx: Context +) -> CreateThemeResponse: + """Create a reusable theme from antd design tokens. + + Accepts a theme name and an antd design-token configuration (json_data), + supplied either as a JSON object or a JSON string. The configuration is + sanitized and validated the same way the REST API validates themes before + the theme is persisted. + + Required fields: + - theme_name: Human-readable name for the theme + - json_data: The antd design-token configuration (dict or JSON string) + + Example: + ```json + { + "theme_name": "Corporate Blue", + "json_data": {"token": {"colorPrimary": "#1d4ed8"}} + } + ``` + + Returns CreateThemeResponse with the new theme's id and uuid on success, + or an error response (error_type="ValidationError") if the configuration + is invalid. + """ + await ctx.info("Creating theme: theme_name=%s" % (request.theme_name,)) + + # Parse json_data into a dict (accept dict or JSON string) + config_dict: dict[str, Any] + if isinstance(request.json_data, str): + try: + parsed = json.loads(request.json_data) + except (TypeError, json.JSONDecodeError) as exc: + await ctx.warning("Invalid JSON in json_data: %s" % (str(exc),)) + return CreateThemeResponse( + success=False, + error=f"json_data is not valid JSON: {exc}", + error_type="ValidationError", + ) + if not isinstance(parsed, dict): + await ctx.warning("json_data did not parse to an object") + return CreateThemeResponse( + success=False, + error="json_data must be a JSON object", + error_type="ValidationError", + ) + config_dict = parsed + else: + config_dict = request.json_data + + # Sanitize and validate using the same routine as the REST API + try: + sanitized = _sanitize_and_validate_theme_config(config_dict) Review Comment: **Suggestion:** Add an explicit type annotation for `sanitized` to keep the validated theme-config variable fully typed. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The new local variable `sanitized` is assigned without an annotation even though it is a relevant typed value in new Python code, so this is a real type-hint omission. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f22757dfe8f8457dbf11a5a7469328c9&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f22757dfe8f8457dbf11a5a7469328c9&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/create_theme.py **Line:** 105:105 **Comment:** *Custom Rule: Add an explicit type annotation for `sanitized` to keep the validated theme-config variable fully typed. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=14a4182a9811710527ae34bc06ac2de48c65ac796e3f7889c2a5019bbe95b7fc&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=14a4182a9811710527ae34bc06ac2de48c65ac796e3f7889c2a5019bbe95b7fc&reaction=dislike'>👎</a> ########## superset/mcp_service/theme/tool/create_theme.py: ########## @@ -0,0 +1,151 @@ +# 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. + +""" +Create theme FastMCP tool + +Creates a reusable Superset theme from an antd design-token configuration. +The supplied json_data is sanitized and validated with the same routine the +REST API uses before the theme is persisted via ThemeDAO. +""" + +import logging +from typing import Any + +from fastmcp import Context +from marshmallow import ValidationError +from sqlalchemy.exc import SQLAlchemyError +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import db, event_logger +from superset.mcp_service.theme.schemas import CreateThemeRequest, CreateThemeResponse +from superset.themes.schemas import _sanitize_and_validate_theme_config +from superset.utils import json + +logger = logging.getLogger(__name__) + + +@tool( + tags=["mutate"], + class_permission_name="Theme", + method_permission_name="write", + annotations=ToolAnnotations( + title="Create theme", + readOnlyHint=False, + destructiveHint=False, + ), +) +async def create_theme( + request: CreateThemeRequest, ctx: Context +) -> CreateThemeResponse: + """Create a reusable theme from antd design tokens. + + Accepts a theme name and an antd design-token configuration (json_data), + supplied either as a JSON object or a JSON string. The configuration is + sanitized and validated the same way the REST API validates themes before + the theme is persisted. + + Required fields: + - theme_name: Human-readable name for the theme + - json_data: The antd design-token configuration (dict or JSON string) + + Example: + ```json + { + "theme_name": "Corporate Blue", + "json_data": {"token": {"colorPrimary": "#1d4ed8"}} + } + ``` + + Returns CreateThemeResponse with the new theme's id and uuid on success, + or an error response (error_type="ValidationError") if the configuration + is invalid. + """ + await ctx.info("Creating theme: theme_name=%s" % (request.theme_name,)) + + # Parse json_data into a dict (accept dict or JSON string) + config_dict: dict[str, Any] + if isinstance(request.json_data, str): + try: + parsed = json.loads(request.json_data) + except (TypeError, json.JSONDecodeError) as exc: + await ctx.warning("Invalid JSON in json_data: %s" % (str(exc),)) + return CreateThemeResponse( + success=False, + error=f"json_data is not valid JSON: {exc}", + error_type="ValidationError", + ) + if not isinstance(parsed, dict): + await ctx.warning("json_data did not parse to an object") + return CreateThemeResponse( + success=False, + error="json_data must be a JSON object", + error_type="ValidationError", + ) + config_dict = parsed + else: + config_dict = request.json_data + + # Sanitize and validate using the same routine as the REST API + try: + sanitized = _sanitize_and_validate_theme_config(config_dict) + except ValidationError as exc: + await ctx.warning("Theme validation failed: %s" % (exc.messages,)) + return CreateThemeResponse( + success=False, + error=str(exc.messages), + error_type="ValidationError", + ) + + try: + from superset.daos.theme import ThemeDAO + + with event_logger.log_context(action="mcp.create_theme"): + theme = ThemeDAO.create( Review Comment: **Suggestion:** Add an explicit type annotation for `theme` when assigning the DAO result so this newly introduced variable is not left untyped. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The variable `theme` is newly introduced and lacks an explicit type annotation, which violates the requirement to type-hint relevant variables in new or modified Python code. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f5609f2df09b4d9cae73e1f3da3fbf39&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f5609f2df09b4d9cae73e1f3da3fbf39&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/create_theme.py **Line:** 118:118 **Comment:** *Custom Rule: Add an explicit type annotation for `theme` when assigning the DAO result so this newly introduced variable is not left untyped. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=91408bbc76dbe283794cab5be891823d2e2196e4799e9347be441b5166601358&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=91408bbc76dbe283794cab5be891823d2e2196e4799e9347be441b5166601358&reaction=dislike'>👎</a> ########## superset/mcp_service/theme/tool/get_theme_info.py: ########## @@ -0,0 +1,111 @@ +# 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. + +""" +Get theme info FastMCP tool + +This module contains the FastMCP tool for getting detailed information +about a specific theme by numeric ID or UUID. +""" + +import logging +from datetime import datetime, timezone + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import event_logger +from superset.mcp_service.mcp_core import ModelGetInfoCore +from superset.mcp_service.theme.schemas import ( + GetThemeInfoRequest, + serialize_theme_object, + ThemeError, + ThemeInfo, +) + +logger = logging.getLogger(__name__) + + +@tool( + tags=["discovery"], + class_permission_name="Theme", + annotations=ToolAnnotations( + title="Get theme info", + readOnlyHint=True, + destructiveHint=False, + ), +) +async def get_theme_info( + request: GetThemeInfoRequest, ctx: Context +) -> ThemeInfo | ThemeError: + """Get theme metadata by numeric ID or UUID. + + Returns theme details including name, system flags, and the antd + design-token configuration (json_data). + + The identifier may be a numeric ID or a UUID string. To find a theme + ID, use the list_themes tool first. + + Example usage: + ```json + { + "identifier": 1 + } + ``` + """ + await ctx.info( + "Retrieving theme information: identifier=%s" % (request.identifier,) + ) + + try: + from superset.daos.theme import ThemeDAO + + with event_logger.log_context(action="mcp.get_theme_info.lookup"): + get_tool = ModelGetInfoCore( + dao_class=ThemeDAO, + output_schema=ThemeInfo, + error_schema=ThemeError, + serializer=serialize_theme_object, + supports_slug=False, + logger=logger, + ) Review Comment: **Suggestion:** Add a type annotation to the tool-core local variable so this newly introduced variable is explicitly typed. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The local variable `get_tool` is newly introduced and its type is clear from the assignment, but it is not annotated. This is a real omission under the type-hint rule for relevant variables. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8a5779119b4540e5a67d242a1c7aa27e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8a5779119b4540e5a67d242a1c7aa27e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/get_theme_info.py **Line:** 78:85 **Comment:** *Custom Rule: Add a type annotation to the tool-core local variable so this newly introduced variable is explicitly typed. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=819e372f4de66b5a263fa3008a1c8a3de13cae071aa6558537810830711adf1c&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=819e372f4de66b5a263fa3008a1c8a3de13cae071aa6558537810830711adf1c&reaction=dislike'>👎</a> ########## superset/mcp_service/theme/tool/list_themes.py: ########## @@ -0,0 +1,163 @@ +# 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. + +""" +List themes FastMCP tool + +This module contains the FastMCP tool for listing themes with filtering, +search, and pagination support. +""" + +import logging + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import event_logger +from superset.mcp_service.mcp_core import ModelListCore +from superset.mcp_service.theme.schemas import ( + ListThemesRequest, + serialize_theme_object, + ThemeError, + ThemeFilter, + ThemeInfo, + ThemeList, +) + +logger = logging.getLogger(__name__) + +DEFAULT_THEME_COLUMNS = [ + "id", + "theme_name", + "is_system_default", + "is_system_dark", +] +SORTABLE_THEME_COLUMNS = ["id", "theme_name", "changed_on", "created_on"] Review Comment: **Suggestion:** Add an explicit type annotation to this sortable-columns constant to satisfy the type-hint requirement for annotatable variables. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This constant is a module-level list and can be annotated, but it is currently untyped, so it matches the type-hint omission rule. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=33380f07126d483099342507fb17ac8b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=33380f07126d483099342507fb17ac8b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/list_themes.py **Line:** 49:49 **Comment:** *Custom Rule: Add an explicit type annotation to this sortable-columns constant to satisfy the type-hint requirement for annotatable variables. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=56f2724b3ae2ce86def653ed5968099dcf71b9606f1d593aed9339749bbbb332&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=56f2724b3ae2ce86def653ed5968099dcf71b9606f1d593aed9339749bbbb332&reaction=dislike'>👎</a> ########## superset/mcp_service/theme/tool/list_themes.py: ########## @@ -0,0 +1,163 @@ +# 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. + +""" +List themes FastMCP tool + +This module contains the FastMCP tool for listing themes with filtering, +search, and pagination support. +""" + +import logging + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import event_logger +from superset.mcp_service.mcp_core import ModelListCore +from superset.mcp_service.theme.schemas import ( + ListThemesRequest, + serialize_theme_object, + ThemeError, + ThemeFilter, + ThemeInfo, + ThemeList, +) + +logger = logging.getLogger(__name__) + +DEFAULT_THEME_COLUMNS = [ + "id", + "theme_name", + "is_system_default", + "is_system_dark", Review Comment: **Suggestion:** Add an explicit type annotation to this module-level constant list so it complies with the required type-hinting rule for relevant variables. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This module-level list is a relevant variable that can be annotated, but it is declared without a type hint, which violates the required Python type-hinting rule. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1d26cc0fa56d45aeadde247c2ee515fa&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1d26cc0fa56d45aeadde247c2ee515fa&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/list_themes.py **Line:** 42:47 **Comment:** *Custom Rule: Add an explicit type annotation to this module-level constant list so it complies with the required type-hinting rule for relevant variables. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=c6b568f81b577016620dc3cfb9fbe5c91083f10fac25de4f1100f12f281fbb1c&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=c6b568f81b577016620dc3cfb9fbe5c91083f10fac25de4f1100f12f281fbb1c&reaction=dislike'>👎</a> ########## superset/mcp_service/theme/tool/list_themes.py: ########## @@ -0,0 +1,163 @@ +# 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. + +""" +List themes FastMCP tool + +This module contains the FastMCP tool for listing themes with filtering, +search, and pagination support. +""" + +import logging + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import event_logger +from superset.mcp_service.mcp_core import ModelListCore +from superset.mcp_service.theme.schemas import ( + ListThemesRequest, + serialize_theme_object, + ThemeError, + ThemeFilter, + ThemeInfo, + ThemeList, +) + +logger = logging.getLogger(__name__) + +DEFAULT_THEME_COLUMNS = [ + "id", + "theme_name", + "is_system_default", + "is_system_dark", +] +SORTABLE_THEME_COLUMNS = ["id", "theme_name", "changed_on", "created_on"] +ALL_THEME_COLUMNS = [ + "id", + "theme_name", + "json_data", + "uuid", + "is_system", + "is_system_default", + "is_system_dark", + "changed_on", + "changed_on_humanized", + "created_on", + "created_on_humanized", +] + +_DEFAULT_LIST_THEMES_REQUEST = ListThemesRequest() Review Comment: **Suggestion:** Add a variable type annotation for this default request instance so the module-level variable is explicitly typed. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This module-level instance is a relevant variable that can be annotated, but it is declared without a type hint, violating the type-hinting requirement. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=bd05b85307c040628e8221c51250fcd3&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=bd05b85307c040628e8221c51250fcd3&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/list_themes.py **Line:** 64:64 **Comment:** *Custom Rule: Add a variable type annotation for this default request instance so the module-level variable is explicitly typed. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=0cd69b3bb55dffa5087c09cd49f7673a73a43c7711c1aa816608e5407f6c5f8e&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=0cd69b3bb55dffa5087c09cd49f7673a73a43c7711c1aa816608e5407f6c5f8e&reaction=dislike'>👎</a> ########## superset/mcp_service/theme/tool/get_theme_info.py: ########## @@ -0,0 +1,111 @@ +# 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. + +""" +Get theme info FastMCP tool + +This module contains the FastMCP tool for getting detailed information +about a specific theme by numeric ID or UUID. +""" + +import logging +from datetime import datetime, timezone + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import event_logger +from superset.mcp_service.mcp_core import ModelGetInfoCore +from superset.mcp_service.theme.schemas import ( + GetThemeInfoRequest, + serialize_theme_object, + ThemeError, + ThemeInfo, +) + +logger = logging.getLogger(__name__) + + +@tool( + tags=["discovery"], + class_permission_name="Theme", + annotations=ToolAnnotations( + title="Get theme info", + readOnlyHint=True, + destructiveHint=False, + ), +) +async def get_theme_info( + request: GetThemeInfoRequest, ctx: Context +) -> ThemeInfo | ThemeError: + """Get theme metadata by numeric ID or UUID. + + Returns theme details including name, system flags, and the antd + design-token configuration (json_data). + + The identifier may be a numeric ID or a UUID string. To find a theme + ID, use the list_themes tool first. + + Example usage: + ```json + { + "identifier": 1 + } + ``` + """ + await ctx.info( + "Retrieving theme information: identifier=%s" % (request.identifier,) + ) + + try: + from superset.daos.theme import ThemeDAO + + with event_logger.log_context(action="mcp.get_theme_info.lookup"): + get_tool = ModelGetInfoCore( + dao_class=ThemeDAO, + output_schema=ThemeInfo, + error_schema=ThemeError, + serializer=serialize_theme_object, + supports_slug=False, + logger=logger, + ) + + result = get_tool.run_tool(request.identifier) Review Comment: **Suggestion:** Add an explicit union type annotation for the result variable to comply with the requirement to type relevant annotatable variables. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The `result` local variable is introduced without a type hint even though it holds the tool's return value and is later type-checked. This is a valid omission under the rule requiring annotations for relevant variables. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0c664f27febc4b54add4975298fd7a1f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0c664f27febc4b54add4975298fd7a1f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/get_theme_info.py **Line:** 87:87 **Comment:** *Custom Rule: Add an explicit union type annotation for the result variable to comply with the requirement to type relevant annotatable variables. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=7a9ce68ef613c6b2593ca263c3df05b979bba9bde77e05fbd8a63c4be789bef9&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=7a9ce68ef613c6b2593ca263c3df05b979bba9bde77e05fbd8a63c4be789bef9&reaction=dislike'>👎</a> ########## superset/mcp_service/theme/tool/list_themes.py: ########## @@ -0,0 +1,163 @@ +# 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. + +""" +List themes FastMCP tool + +This module contains the FastMCP tool for listing themes with filtering, +search, and pagination support. +""" + +import logging + +from fastmcp import Context +from superset_core.mcp.decorators import tool, ToolAnnotations + +from superset.extensions import event_logger +from superset.mcp_service.mcp_core import ModelListCore +from superset.mcp_service.theme.schemas import ( + ListThemesRequest, + serialize_theme_object, + ThemeError, + ThemeFilter, + ThemeInfo, + ThemeList, +) + +logger = logging.getLogger(__name__) + +DEFAULT_THEME_COLUMNS = [ + "id", + "theme_name", + "is_system_default", + "is_system_dark", +] +SORTABLE_THEME_COLUMNS = ["id", "theme_name", "changed_on", "created_on"] +ALL_THEME_COLUMNS = [ + "id", + "theme_name", + "json_data", + "uuid", + "is_system", + "is_system_default", + "is_system_dark", + "changed_on", + "changed_on_humanized", + "created_on", + "created_on_humanized", +] Review Comment: **Suggestion:** Add an explicit type annotation to this module-level list constant to align with the rule requiring type hints on relevant variables. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This is another module-level list constant that can be annotated, but it lacks an explicit type hint, so the rule applies. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=37dafd143f7246789f0ded9220825838&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=37dafd143f7246789f0ded9220825838&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/mcp_service/theme/tool/list_themes.py **Line:** 50:62 **Comment:** *Custom Rule: Add an explicit type annotation to this module-level list constant to align with the rule requiring type hints on relevant variables. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=f26e6cb5ed6fbd20a067f57abb1bbdcbe0b0560f7509cd226d39e1977a858d83&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41497&comment_hash=f26e6cb5ed6fbd20a067f57abb1bbdcbe0b0560f7509cd226d39e1977a858d83&reaction=dislike'>👎</a> -- 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]
