Skip to content

[py] fix incompatible types in url_to_be() function #14298

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

Draft
wants to merge 10 commits into
base: trunk
Choose a base branch
from

Conversation

navin772
Copy link
Member

@navin772 navin772 commented Jul 24, 2024

User description

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Fixes #13544
The url_to_be() function had an incompatible type as reported by mypy.
We can change the any_of() function params to make it compatible.

Motivation and Context

Types of changes

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Bug fix


Description

  • Fixed incompatible types in the url_to_be function as reported by mypy.
  • Updated the return type of the url_to_be function to include Union[bool, List[WebElement], WebElement, Literal[False]].
  • Modified the _predicate function to return Literal[False] if the URL does not match.

Changes walkthrough 📝

Relevant files
Bug fix
expected_conditions.py
Fix incompatible return types in `url_to_be` function       

py/selenium/webdriver/support/expected_conditions.py

  • Updated the return type of url_to_be function to include multiple
    possible types.
  • Modified the _predicate function to return Literal[False] if the URL
    does not match.
  • +3/-3     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @qodo-merge-pro qodo-merge-pro bot added P-bug fix PR addresses a known issue Review effort [1-5]: 2 labels Jul 24, 2024
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Incorrect Return Type
    The use of Literal[False] in the return type of _predicate function is incorrect. It should be bool instead, as Literal[False] is not a valid return type and does not make sense in this context. The correct return type should be bool to indicate a true or false condition.

    Copy link
    Contributor

    qodo-merge-pro bot commented Jul 24, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    ✅ Simplify the return statement by using False instead of Literal[False]
    Suggestion Impact:The suggestion to replace `Literal[False]` with `False` in the return statement was implemented in the commit.

    code diff:

    -        return url == driver.current_url or Literal[False]
    +        return url == driver.current_url or False

    Replace the use of Literal[False] with False in the return statement. Literal[False]
    is not necessary and can be replaced with the boolean value False directly for
    clarity and correctness.

    py/selenium/webdriver/support/expected_conditions.py [125]

    -return url == driver.current_url or Literal[False]
    +return url == driver.current_url or False
     
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: The suggestion improves code clarity and correctness by replacing Literal[False] with the boolean value False, which is more appropriate in this context.

    9

    @navin772 navin772 marked this pull request as draft August 6, 2024 08:26
    @navin772
    Copy link
    Member Author

    navin772 commented Aug 7, 2024

    Moving to draft as it needs clarification from issue author - #13544

    @VietND96 VietND96 added the C-py Python Bindings label Nov 19, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    C-py Python Bindings P-bug fix PR addresses a known issue Review effort [1-5]: 2
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    [🐛 Bug]: mypy detects incompatible types
    4 participants