[py] Fix return type hint for `alert_is_present` by nemowang2003 · Pull Request #16975 · SeleniumHQ/selenium

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟡
🎫 #1234
🔴 Restore/fix behavior so that clicking a link whose href contains JavaScript triggers the
JavaScript (alert) as it did in Selenium 2.47.1, but fails in 2.48.x on Firefox 42.
Ensure the provided repro/test case produces the expected alert on the affected Firefox
setup.
🟡
🎫 #5678
🔴 Investigate and fix "Error: ConnectFailure (Connection refused)" occurring on subsequent
ChromeDriver instantiations on Ubuntu 16.04 / Chrome 65 / ChromeDriver 2.35 / Selenium
3.9.0.
Ensure multiple consecutive ChromeDriver instantiations do not emit the ConnectFailure
error in console/logs.
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Literal import check: The new return annotation uses Literal[False] and may cause a runtime/import-time failure
if Literal is not imported or if annotations are not postponed in this module.

Referred Code
def alert_is_present() -> Callable[[WebDriver], Alert | Literal[False]]:
    """Check that an alert is present and switch to it.

Learn more about managing compliance generic rules or creating your own custom rules

  • Update