Skip to content

fix: rename variable to avoid shadowing builtin type - #184

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260602-101804-356781f5
Open

fix: rename variable to avoid shadowing builtin type#184
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260602-101804-356781f5

Conversation

@sonarqube-agent

Copy link
Copy Markdown

This PR was created because a team member assigned these issues to the Remediation Agent.

Renamed the local variable type to cmd_type in discord/app_commands/commands.py to avoid shadowing Python's built-in type function. This improves code clarity and prevents potential issues from obscuring the builtin function.

View Project in SonarCloud


Fixed Issues

python:S5806 - Rename this variable; it shadows a builtin. • MAJORView issue

Location: discord/app_commands/commands.py:450

Why is this an issue?

Defining a variable with the same name as a built-in symbol will "shadow" it. That means that the builtin will no longer be accessible through its original name, having locally been replaced by the variable.

What changed

Renames the local variable type to cmd_type to avoid shadowing the Python builtin type. The original code used type as a local variable name on line 450, which shadows the built-in type function, making the code harder to read and potentially error-prone. By renaming it to cmd_type, the builtin remains accessible and the code is clearer.

--- a/discord/app_commands/commands.py
+++ b/discord/app_commands/commands.py
@@ -450,2 +450,2 @@ def _get_context_menu_parameter(func: ContextMenuCallback) -> Tuple[str, Any, Ap
-    type = _context_menu_annotation(resolved)
-    return (parameter.name, resolved, type)
+    cmd_type = _context_menu_annotation(resolved)
+    return (parameter.name, resolved, cmd_type)

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZUnUZf_U1G2OajCqWoo for python:S5806 rule

Generated by SonarQube Agent (task: 4ea4fd8b-6fc0-49bb-a7e3-a2d5e321cbc0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant