Skip to content

feat: add literal identity comparison bug pattern for Python#1034

Open
VasuNagar11 wants to merge 3 commits into
imDarshanGK:mainfrom
VasuNagar11:feat/TBD
Open

feat: add literal identity comparison bug pattern for Python#1034
VasuNagar11 wants to merge 3 commits into
imDarshanGK:mainfrom
VasuNagar11:feat/TBD

Conversation

@VasuNagar11

Copy link
Copy Markdown

Description

This PR implements a static analysis rule to flag instances where string or integer literals are compared using identity operators (is / is not) instead of value equality operators (== / !=). Using identity operators on primitive types checks object memory reference identity rather than value equality, which introduces unpredictable runtime evaluation bugs because Python caches small integers and short strings arbitrarily.

Related Issue

Fixes #820

Type of change

  • Bug fix
  • New feature / enhancement
  • Documentation update
  • Test addition
  • Refactor

Checklist

  • I have read CONTRIBUTING.md
  • My branch is up to date with main
  • I have run pytest -v and all tests pass
  • I have not introduced duplicate issues or features
  • My PR title follows the format: feat/fix/docs/test: short description
  • I have added tests for new features (Level 2 and 3 issues)
  • No hardcoded secrets or API keys in my code
  • This PR is linked to a GSSoC 2026 issue

Screenshots (if frontend change)

N/A (Backend logic addition)

Test evidence

pytest -v
============================= test session starts ==============================
plugins: anyio-4.3.0
collected 56 items

backend/tests/test_endpoints.py::test_debug_detects_literal_identity PASSED
# ... [All 56 tests passed successfully] ...
============================= 56 passed in 0.84s ===============================

@imDarshanGK imDarshanGK left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terminal output alone is not enough. Please add a UI/demo flow (video or screenshots) so the feature behavior can be clearly verified.

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.

[Feature] feat(backend): Add static rule to detect 'Literal Identity Comparison' in Python

2 participants