codeant-ai-for-open-source[bot] commented on code in PR #41176: URL: https://github.com/apache/superset/pull/41176#discussion_r3555069874
########## superset/versioning/api_helpers.py: ########## @@ -0,0 +1,219 @@ +# 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. +"""Shared handlers for the ``/versions/`` REST endpoints. + +Each ``ChartRestApi`` / ``DashboardRestApi`` / ``DatasetRestApi`` carries +the same read endpoint methods — ``list_versions`` and ``get_version`` — +whose bodies are byte-for-byte identical apart from the model class and +the ``security_manager.raise_for_access`` kwarg. Extracting the bodies +here lets each per-resource method collapse to a single delegation call, +while the OpenAPI docstring + FAB decorators stay at the method site +where they belong. + +(The restore endpoint ships in a later PR; only the read endpoints are +wired here.) +""" + +from __future__ import annotations + +from dataclasses import dataclass +from typing import Any +from uuid import UUID + +import sqlalchemy as sa +from flask import current_app, Response +from flask_appbuilder import Model + +from superset.daos.version import VersionDAO +from superset.exceptions import SupersetSecurityException +from superset.extensions import db, security_manager +from superset.versioning.etag import set_version_etag_by_uuid +from superset.versioning.schemas import VersionListItemSchema + +#: Serializer for version rows (list items and the ``_version`` block of a +#: single-version snapshot — same shape). Dumping through marshmallow +#: instead of handing raw dicts to ``jsonify`` keeps ``issued_at`` +#: ISO-8601 (Flask's default JSON provider renders datetimes as RFC-1123 +#: http-dates) and ``version_uuid`` consistently a string (the list rows +#: carry UUID instances, the snapshot block pre-stringifies). +_version_item_schema = VersionListItemSchema() Review Comment: **Suggestion:** Add an explicit type annotation to this module-level schema variable to satisfy the type-hint requirement for relevant variables. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The custom rule requires type hints on relevant variables when they can be annotated. This module-level schema instance is newly introduced and lacks an explicit type annotation, so the suggestion correctly identifies a real violation. </details> <details> <summary><b>Rule source 📖 </b></summary> .cursor/rules/dev-standard.mdc (line 28) </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=965055f6bf4241e0b8da8a0a33fa336b&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=965055f6bf4241e0b8da8a0a33fa336b&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/versioning/api_helpers.py **Line:** 53:53 **Comment:** *Custom Rule: Add an explicit type annotation to this module-level schema variable to satisfy the type-hint requirement 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%2F41176&comment_hash=a9abb67de687475097090782b31a1351c084bc91de714bb88a6fc68d42abc79a&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41176&comment_hash=a9abb67de687475097090782b31a1351c084bc91de714bb88a6fc68d42abc79a&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]
