[PR #22594] [MERGED] refactor: modernize type hints and imports in access_control module #65630

Closed
opened 2026-05-06 11:31:15 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22594
Author: @ashm-dev
Created: 3/11/2026
Status: Merged
Merged: 3/11/2026
Merged by: @tjbck

Base: devHead: refac/access-control-type-hints


📝 Commits (1)

  • 44d5d9a refac: modernize type hints and imports in access_control module

📊 Changes

2 files changed (+32 additions, -32 deletions)

View changed files

📝 backend/open_webui/utils/access_control/__init__.py (+28 -29)
📝 backend/open_webui/utils/access_control/files.py (+4 -3)

📄 Description

Pull Request Checklist

  • Target branch: dev
  • Description: See below
  • Changelog: See below
  • Documentation: No user-facing changes, docs update not needed
  • Dependencies: No new dependencies. sqlalchemy already used throughout the project.
  • Testing: No logic changes — only type annotations and import ordering. Verified no runtime behavior is affected.
  • Agentic AI Code: Changes reviewed and verified manually.
  • Code review: Self-reviewed.
  • Design & Architecture: No new settings or UX changes.
  • Git Hygiene: Single atomic commit, rebased on dev.
  • Title Prefix: refactor

Changelog Entry

Description

  • Modernize type annotations in access_control/__init__.py and access_control/files.py to use built-in generics and PEP 604 union syntax. Replace untyped db: Optional[Any] with db: Session | None for better static analysis and IDE support.

Added

  • N/A

Changed

  • Replaced typing.Dict, List, Set, Optional with built-in dict, list, set and X | None syntax (PEP 585 / PEP 604)
  • Typed db parameter as Session | None instead of Optional[Any] across all functions in both files
  • Moved mid-file import of access_grants helpers to top-level imports in __init__.py
  • Removed unused Users import from __init__.py
  • Unified Session import style to from sqlalchemy.orm import Session in both files

Deprecated

  • N/A

Removed

  • Unused Users import from open_webui.models.users
  • Redundant typing imports (Dict, List, Set, Optional, Union)

Fixed

  • N/A

Security

  • N/A

Breaking Changes

  • N/A

Additional Information

  • No runtime behavior changes — purely type annotation and import cleanup
  • Requires Python 3.10+ (project already targets this)

Screenshots or Videos

  • N/A (no UI changes)

Contributor License Agreement


🔄 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/22594 **Author:** [@ashm-dev](https://github.com/ashm-dev) **Created:** 3/11/2026 **Status:** ✅ Merged **Merged:** 3/11/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `refac/access-control-type-hints` --- ### 📝 Commits (1) - [`44d5d9a`](https://github.com/open-webui/open-webui/commit/44d5d9a190381b782e55fa3c9e71792af91be608) refac: modernize type hints and imports in access_control module ### 📊 Changes **2 files changed** (+32 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/access_control/__init__.py` (+28 -29) 📝 `backend/open_webui/utils/access_control/files.py` (+4 -3) </details> ### 📄 Description # Pull Request Checklist - [x] **Target branch:** `dev` - [x] **Description:** See below - [x] **Changelog:** See below - [ ] **Documentation:** No user-facing changes, docs update not needed - [x] **Dependencies:** No new dependencies. `sqlalchemy` already used throughout the project. - [x] **Testing:** No logic changes — only type annotations and import ordering. Verified no runtime behavior is affected. - [x] **Agentic AI Code:** Changes reviewed and verified manually. - [x] **Code review:** Self-reviewed. - [x] **Design & Architecture:** No new settings or UX changes. - [x] **Git Hygiene:** Single atomic commit, rebased on `dev`. - [x] **Title Prefix:** `refactor` # Changelog Entry ### Description - Modernize type annotations in `access_control/__init__.py` and `access_control/files.py` to use built-in generics and PEP 604 union syntax. Replace untyped `db: Optional[Any]` with `db: Session | None` for better static analysis and IDE support. ### Added - N/A ### Changed - Replaced `typing.Dict`, `List`, `Set`, `Optional` with built-in `dict`, `list`, `set` and `X | None` syntax (PEP 585 / PEP 604) - Typed `db` parameter as `Session | None` instead of `Optional[Any]` across all functions in both files - Moved mid-file import of `access_grants` helpers to top-level imports in `__init__.py` - Removed unused `Users` import from `__init__.py` - Unified `Session` import style to `from sqlalchemy.orm import Session` in both files ### Deprecated - N/A ### Removed - Unused `Users` import from `open_webui.models.users` - Redundant `typing` imports (`Dict`, `List`, `Set`, `Optional`, `Union`) ### Fixed - N/A ### Security - N/A ### Breaking Changes - N/A --- ### Additional Information - No runtime behavior changes — purely type annotation and import cleanup - Requires Python 3.10+ (project already targets this) ### Screenshots or Videos - N/A (no UI changes) ### Contributor License Agreement - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <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-05-06 11:31:15 -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#65630