korbit-ai[bot] commented on code in PR #34345:
URL: https://github.com/apache/superset/pull/34345#discussion_r2246168352


##########
superset/cli/main.py:
##########
@@ -22,28 +22,46 @@
 
 import click
 from colorama import Fore, Style
+from flask import current_app
 from flask.cli import FlaskGroup, with_appcontext
 
-from superset import app, appbuilder, cli, security_manager
-from superset.cli.lib import normalize_token
+from superset import appbuilder, cli, security_manager
 from superset.extensions import db
 from superset.utils.decorators import transaction
 
 logger = logging.getLogger(__name__)
 
 
+def normalize_token(token_name: str) -> str:
+    """
+    As of click>=7, underscores in function names are replaced by dashes.
+    To avoid the need to rename all cli functions, e.g. load_examples to
+    load-examples, this function is used to convert dashes back to
+    underscores.
+
+    :param token_name: token name possibly containing dashes
+    :return: token name where dashes are replaced with underscores
+    """
+    return token_name.replace("_", "-")
+
+
+def create_app() -> Any:
+    """Create app instance for CLI"""
+    from superset.app import create_app as create_superset_app
+
+    return create_superset_app()
+
+
 @click.group(
     cls=FlaskGroup,
+    create_app=create_app,
     context_settings={"token_normalize_func": normalize_token},
 )
 @with_appcontext
 def superset() -> None:
     """\033[1;37mThe Apache Superset CLI\033[0m"""
     # NOTE: codes above are ANSI color codes for bold white in CLI header ^^^
-
-    @app.shell_context_processor
-    def make_shell_context() -> dict[str, Any]:
-        return {"app": app, "db": db}
+    pass

Review Comment:
   Good catch! You're right - the `pass` statement is redundant here since the 
function already has a docstring. Would you like me to update the suggested 
change to remove it?



-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to