codeant-ai-for-open-source[bot] commented on code in PR #39469: URL: https://github.com/apache/superset/pull/39469#discussion_r3442937829
########## superset/models/user_session_auth_stamp.py: ########## @@ -0,0 +1,46 @@ +# 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. +"""Per-user stamp used to invalidate browser sessions after password changes.""" + +from __future__ import annotations + +from flask_appbuilder import Model +from sqlalchemy import Column, ForeignKey, Integer, String +from sqlalchemy.orm import relationship + +from superset import security_manager + + +class UserSessionAuthStamp(Model): + """ + One row per ``ab_user`` holding a stamp copied into the Flask session at login. + + Bumping ``stamp`` invalidates every session that still carries an older value. + """ + + __tablename__ = "user_session_auth_stamp" + + user_id = Column(Integer, ForeignKey("ab_user.id", ondelete="CASCADE"), primary_key=True) + stamp = Column(String(36), nullable=False) + + user = relationship( + security_manager.user_model, + foreign_keys=[user_id], + ) + + def __repr__(self) -> str: + return f"<UserSessionAuthStamp user_id={self.user_id}>" Review Comment: **Suggestion:** Add an inline docstring to this newly added function so it complies with the requirement that new functions are documented. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The rule requires newly added Python functions to include docstrings. This new `__repr__` method has no docstring, so the suggestion correctly identifies a real violation. </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ccf58f7f2db54b5780fd82dd95042ca2&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=ccf58f7f2db54b5780fd82dd95042ca2&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/models/user_session_auth_stamp.py **Line:** 45:46 **Comment:** *Custom Rule: Add an inline docstring to this newly added function so it complies with the requirement that new functions are documented. 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%2F39469&comment_hash=18d37c3930e2be13e23bb1150806c9aa6bbc79433e3c7c222c81f160eeda369c&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39469&comment_hash=18d37c3930e2be13e23bb1150806c9aa6bbc79433e3c7c222c81f160eeda369c&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]
