[PR #21437] [CLOSED] fix: use 'is None' instead of '== None' in socket handler #26078

Closed
opened 2026-04-20 06:18:31 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21437
Author: @aviu16
Created: 2/15/2026
Status: Closed

Base: mainHead: fix-none-comparison


📝 Commits (1)

  • fea8cf8 fix: use 'is None' instead of '== None' in socket handler

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 backend/open_webui/socket/main.py (+1 -1)

📄 Description

Summary

Replace equality comparison with identity check for None value in socket message handler.

Changes

  • data.get("type") == Nonedata.get("type") is None

Why

According to PEP 8, comparisons to singletons like None should always be done with is or is not, never the equality operators == or !=.

This is because:

  1. Identity checks (is) are faster than equality checks (==)
  2. None is a singleton, so identity comparison is semantically correct
  3. Using == can lead to unexpected behavior if a class overrides __eq__

Test plan

Existing tests should pass. This is a code quality improvement that maintains identical behavior.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/21437 **Author:** [@aviu16](https://github.com/aviu16) **Created:** 2/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-none-comparison` --- ### 📝 Commits (1) - [`fea8cf8`](https://github.com/open-webui/open-webui/commit/fea8cf896d8b4a2ab86af5097c1775d994a6d39b) fix: use 'is None' instead of '== None' in socket handler ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/socket/main.py` (+1 -1) </details> ### 📄 Description ## Summary Replace equality comparison with identity check for None value in socket message handler. ## Changes - `data.get("type") == None` → `data.get("type") is None` ## Why According to [PEP 8](https://peps.python.org/pep-0008/#programming-recommendations), comparisons to singletons like `None` should always be done with `is` or `is not`, never the equality operators `==` or `!=`. This is because: 1. Identity checks (`is`) are faster than equality checks (`==`) 2. `None` is a singleton, so identity comparison is semantically correct 3. Using `==` can lead to unexpected behavior if a class overrides `__eq__` ## Test plan Existing tests should pass. This is a code quality improvement that maintains identical behavior. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 06:18:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#26078