bito-code-review[bot] commented on code in PR #36308:
URL: https://github.com/apache/superset/pull/36308#discussion_r2569561269
##########
superset-extensions-cli/src/superset_extensions_cli/cli.py:
##########
@@ -404,19 +404,28 @@ def backend_watcher() -> None:
@app.command()
-def init() -> None:
- id_ = click.prompt("Extension ID (unique identifier, alphanumeric only)",
type=str)
[email protected]("--id", "id_opt", default=None, help="Extension ID (alphanumeric
and underscores only)")
[email protected]("--name", "name_opt", default=None, help="Extension display
name")
[email protected]("--version", "version_opt", default=None, help="Initial version
(default: 0.1.0)")
[email protected]("--license", "license_opt", default=None, help="License
(default: Apache-2.0)")
[email protected]("--frontend/--no-frontend", "frontend_opt", default=None,
help="Include frontend")
[email protected]("--backend/--no-backend", "backend_opt", default=None,
help="Include backend")
+def init(id_opt: str | None, name_opt: str | None, version_opt: str | None,
license_opt: str | None, frontend_opt: bool | None, backend_opt: bool | None)
-> None:
+ # Check if running in non-interactive mode (required options provided)
+ non_interactive = id_opt is not None and name_opt is not None and
frontend_opt is not None and backend_opt is not None
+
+ id_ = id_opt or click.prompt("Extension ID (unique identifier,
alphanumeric only)", type=str)
if not re.match(r"^[a-zA-Z0-9_]+$", id_):
click.secho(
"❌ ID must be alphanumeric (letters, digits, underscore).",
fg="red"
)
sys.exit(1)
- name = click.prompt("Extension name (human-readable display name)",
type=str)
- version = click.prompt("Initial version", default="0.1.0")
- license = click.prompt("License", default="Apache-2.0")
- include_frontend = click.confirm("Include frontend?", default=True)
- include_backend = click.confirm("Include backend?", default=True)
+ name = name_opt or click.prompt("Extension name (human-readable display
name)", type=str)
+ version = version_opt if version_opt is not None else ("0.1.0" if
non_interactive else click.prompt("Initial version", default="0.1.0"))
+ license = license_opt if license_opt is not None else ("Apache-2.0" if
non_interactive else click.prompt("License", default="Apache-2.0"))
+ include_frontend = frontend_opt if frontend_opt is not None else
click.confirm("Include frontend?", default=True)
+ include_backend = backend_opt if backend_opt is not None else
click.confirm("Include backend?", default=True)
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Variable shadows Python builtin</b></div>
<div id="fix">
Variable `license` shadows the Python builtin `license` (A001). Rename to
`license_str` or similar to avoid shadowing.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
license_str = license_opt if license_opt is not None else ("Apache-2.0"
if non_interactive else click.prompt("License", default="Apache-2.0"))
include_frontend = frontend_opt if frontend_opt is not None else
click.confirm("Include frontend?", default=True)
include_backend = backend_opt if backend_opt is not None else
click.confirm("Include backend?", default=True)
````
</div>
</details>
</div>
<small><i>Code Review Run <a
href=https://github.com/apache/superset/pull/36308#issuecomment-3586798611>#39fbc6</a></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]