Skip to content

[py] Use native dict for type annotation #16157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2025

Conversation

cgoldberg
Copy link
Contributor

@cgoldberg cgoldberg commented Aug 11, 2025

User description

💥 What does this PR do?

Use native dict instead of typing.Dict for annotation in py/selenium/webdriver/common/bidi/session.py.

🔧 Implementation Notes

no functional changes

🔄 Types of changes

  • Bug fix (backwards compatible)

PR Type

Other


Description

  • Replace typing.Dict with native dict type annotation

  • Remove unused Dict import from typing module


File Walkthrough

Relevant files
Formatting
session.py
Replace typing.Dict with native dict annotation                   

py/selenium/webdriver/common/bidi/session.py

  • Removed Dict import from typing module
  • Changed Dict[str, str] to dict[str, str] in method return type
+2/-2     

@selenium-ci selenium-ci added C-py Python Bindings B-devtools Includes everything BiDi or Chrome DevTools related labels Aug 11, 2025
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Typing Compatibility

Using native dict[str, str] requires Python 3.9+. Verify project/package minimum Python version and type-checker configuration; if older versions are supported, this change could break runtime parsing or type checking.

def to_dict(self) -> dict[str, str]:
    """Convert the UserPromptHandler to a dictionary for BiDi protocol.

    Returns:
    -------
Unused Import Check

Ensure Optional is actually used in this file; if not, remove the import to avoid lint warnings since Dict was removed.

from typing import Optional

from selenium.webdriver.common.bidi.common import command_builder

Copy link
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

@cgoldberg cgoldberg merged commit a59ddb4 into SeleniumHQ:trunk Aug 11, 2025
7 of 8 checks passed
@cgoldberg cgoldberg deleted the py-native-dict branch August 11, 2025 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-devtools Includes everything BiDi or Chrome DevTools related C-py Python Bindings Review effort 1/5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants