Skip to content
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

Replace unused variable in lambda expression #2160

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

b2m
Copy link

@b2m b2m commented Feb 4, 2025

User description

Description

In Python it is common to indicate unused variables by choosing _ (underscore) as variable name. This pull request replaces some instances of unused variables in lambda expressions to align with Python customs and also other test examples in the repository.

Types of changes

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • Code example added (and I also added the example to all translated languages)
  • Improved translation
  • Added new translation (and I also added a notice to each document missing translation)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

PR Type

Enhancement


Description

  • Replaced unused variables in lambda expressions with _ for Python convention.

  • Improved code readability and consistency with Python customs.


Changes walkthrough 📝

Relevant files
Enhancement
test_waits.py
Update lambda expressions to use `_` for unused variables

examples/python/tests/waits/test_waits.py

  • Replaced d with _ in lambda expressions to indicate unused variables.
  • Updated two test cases (test_explicit and test_explicit_options) for
    better readability.
  • +2/-2     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • In Python it is common to indicate unused variables by choosing _
    (underscore) as variable name. This commit replaces some instances of
    unused variables in lambda expressions to align with Python customs
    and also other test examples in the repository.
    Copy link

    netlify bot commented Feb 4, 2025

    👷 Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    🔨 Latest commit 354c9a0

    @CLAassistant
    Copy link

    CLAassistant commented Feb 4, 2025

    CLA assistant check
    All committers have signed the CLA.

    Copy link
    Contributor

    qodo-merge-pro bot commented Feb 4, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    Copy link
    Contributor

    qodo-merge-pro bot commented Feb 4, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Avoid side effects in wait conditions

    The lambda expression in test_explicit_options uses a side effect (send_keys)
    within the wait condition, which is an anti-pattern. Move the send_keys
    operation after the wait condition.

    examples/python/tests/waits/test_waits.py [55]

    -wait.until(lambda _ : revealed.send_keys("Displayed") or True)
    +wait.until(lambda _ : revealed.is_displayed())
    +revealed.send_keys("Displayed")
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Having side effects (send_keys) in a wait condition is a poor practice that can lead to race conditions and flaky tests. Moving the send_keys operation after waiting for visibility makes the test more reliable and follows better testing patterns.

    9

    @b2m
    Copy link
    Author

    b2m commented Feb 4, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:
    Category Suggestion Score
    General
    Avoid side effects in wait conditions

    9

    As the example is explicitly on how side effects can be achieved the suggestion is imho a false positive.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants