Skip to content

[py] fix return type and docstring of get_downloadable_files #15292

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 4 commits into from
Feb 17, 2025

Conversation

Delta456
Copy link
Member

@Delta456 Delta456 commented Feb 17, 2025

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.

Fixes doc and code comment for get_downloadable_files as per #15288 in Python binding

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

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, Documentation, Tests


Description

  • Fixed the return type of get_downloadable_files to list.

  • Updated the docstring of get_downloadable_files to reflect the correct return type.

  • Added a test assertion to verify the return type of get_downloadable_files.


Changes walkthrough 📝

Relevant files
Bug fix
webdriver.py
Update `get_downloadable_files` return type and docstring

py/selenium/webdriver/remote/webdriver.py

  • Changed the return type of get_downloadable_files from dict to list.
  • Updated the docstring to describe the return type as a list of file
    names.
  • +2/-3     
    Tests
    remote_downloads_tests.py
    Add test for `get_downloadable_files` return type               

    py/test/selenium/webdriver/remote/remote_downloads_tests.py

  • Added a test assertion to check that get_downloadable_files returns a
    list.
  • Verified the presence of specific file names in the returned list.
  • +1/-0     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    15288 - Fully compliant

    Compliant requirements:

    • Fix incorrect return type documentation for get_downloadable_files() method
    • Fix incorrect docstring description for get_downloadable_files() method
    • Verify actual return type matches documentation
    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Use isinstance for type checking

    Replace type check with isinstance() for more robust type checking that handles
    subclasses correctly.

    py/test/selenium/webdriver/remote/remote_downloads_tests.py [31]

    -assert type(file_names) is list
    +assert isinstance(file_names, list)
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: Using isinstance() is a more robust way to check types as it properly handles inheritance. This is a meaningful improvement to the test's reliability.

    Medium
    Learned
    best practice
    Use specific collection type hints that include the element type instead of generic collection types

    The return type hint list is too generic. Since this method returns a list of
    strings (file names), use the more specific type hint List[str]. Don't forget to
    import List from typing.

    py/selenium/webdriver/remote/webdriver.py [1384]

    -def get_downloadable_files(self) -> list:
    +from typing import List
     
    +def get_downloadable_files(self) -> List[str]:
    +
    • Apply this suggestion
    Suggestion importance[1-10]: 6
    Low
    • More

    @VietND96 VietND96 merged commit 036be09 into SeleniumHQ:trunk Feb 17, 2025
    16 of 17 checks passed
    @VietND96
    Copy link
    Member

    VietND96 commented Feb 17, 2025

    This update also helps the implementation align with behavior in Java binding #15293.

    sandeepsuryaprasad pushed a commit to sandeepsuryaprasad/selenium that referenced this pull request Mar 23, 2025
    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