Skip to content

fix: use removesuffix("Def") instead of [:-3] for elementKind extraction#63

Merged
jimisola merged 2 commits intomainfrom
copilot/sub-pr-61
Mar 1, 2026
Merged

fix: use removesuffix("Def") instead of [:-3] for elementKind extraction#63
jimisola merged 2 commits intomainfrom
copilot/sub-pr-61

Conversation

Copy link
Contributor

Copilot AI commented Mar 1, 2026

node.__class__.__name__[:-3] used a magic number to strip "Def" from AST node class names (FunctionDef, AsyncFunctionDef, ClassDef). While correct, it silently truncates incorrectly for any class name not ending in exactly 3 chars.

Change

  • Replace [:-3] with .removesuffix("Def") — explicit about what's being stripped, no-op for names that don't end in "Def"
# Before
"elementKind": node.__class__.__name__[:-3].upper()

# After
"elementKind": node.__class__.__name__.removesuffix("Def").upper()

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Drop support for Python 3.10–3.12 and require Python 3.13 fix: use removesuffix("Def") instead of [:-3] for elementKind extraction Mar 1, 2026
Base automatically changed from feat/python-3-13 to main March 1, 2026 10:24
Co-authored-by: jimisola <1577689+jimisola@users.noreply.github.com>
@jimisola jimisola force-pushed the copilot/sub-pr-61 branch from 79a0bfe to 2a2c30d Compare March 1, 2026 10:30
@jimisola jimisola marked this pull request as ready for review March 1, 2026 10:39
@jimisola jimisola merged commit b32f203 into main Mar 1, 2026
9 checks passed
@jimisola jimisola deleted the copilot/sub-pr-61 branch March 1, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants