-
-
Notifications
You must be signed in to change notification settings - Fork 327
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, browser_preferences in ChromiumOptions is a generic dict without type safety, making it error-prone and difficult to maintain.
Problems:
No type validation: _browser_preferences: dict accepts any structure
Unsafe path access: _set_pref_path(path: list, value) - no type checking on paths or values
Silent failures: _get_pref_path() returns None without proper Optional typing
Generic exception: WrongPrefsDict doesn't indicate what's wrong
No autocomplete: IDE can't suggest available preference keys
Proposed Solution:
- Create TypedDict for preferences structure:
from typing import TypedDict, NotRequired
class DownloadPreferences(TypedDict, total=False):
default_directory: str
prompt_for_download: bool
class ProfilePreferences(TypedDict, total=False):
password_manager_enabled: bool
default_content_setting_values: NotRequired[dict[str, int]]
class BrowserPreferences(TypedDict, total=False):
download: DownloadPreferences
profile: ProfilePreferences
intl: NotRequired[dict[str, str]]
plugins: NotRequired[dict[str, bool]]
credentials_enable_service: bool- Update method signatures
- Add specific exceptions
- Add preference path validation
SZRabinowitz
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request