Skip to content

Fix unreachable exception in USBClient initialization and add wda_bundle_id parameter#172

Open
Copilot wants to merge 4 commits into
masterfrom
copilot/fix-code-issue-and-suggestions
Open

Fix unreachable exception in USBClient initialization and add wda_bundle_id parameter#172
Copilot wants to merge 4 commits into
masterfrom
copilot/fix-code-issue-and-suggestions

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 30, 2025

The RuntimeError in USBClient.__init__ was unreachable due to a return statement preceding the raise, making WDA readiness validation ineffective.

Changes

USBClient.init (line 1765-1776)

# Before: exception never thrown
if self.is_ready():
    return

    raise RuntimeError("WDA is not ready after waiting for 20 seconds")

# After: proper timeout with error handling and future-ready API
def __init__(self, udid: str = "", port: int = 8100, wda_bundle_id: str = None):
    ...
    if not self.wait_ready(timeout=20, noprint=True):
        raise RuntimeError("WDA is not ready after waiting for 20 seconds")
  • Replaced single is_ready() check with wait_ready(timeout=20) to match error message semantics
  • Fixed control flow to make exception reachable when WDA fails to initialize
  • Added wda_bundle_id parameter to support future functionality (currently unused but available for extension)

Selector._fix_xcui_type (line 1350)

  • Added raw string prefix to regex replacement: r'/XCUIElementType\g<1>' to eliminate SyntaxWarning

API Changes

The USBClient constructor now accepts an optional wda_bundle_id parameter:

driver = wda.USBClient(udid=self.udid, port=8100, wda_bundle_id=self.wda_bundle_id)

This parameter is reserved for future use and maintains backward compatibility with existing code.

Original prompt

This section details on the original issue you should resolve

<issue_title>新版本代码漏检以及建议</issue_title>
<issue_description>这个异常看起来不会抛出
Image

请问移除了tidevice会计划引入go-ios或pymobiledevice3吗?还是说启动wda由用户自行解决?</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: codeskyblue <3281689+codeskyblue@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code detection issue and provide suggestions Fix unreachable exception in USBClient initialization Oct 30, 2025
Copilot AI requested a review from codeskyblue October 30, 2025 08:33
@codeskyblue
Copy link
Copy Markdown
Member

try to support

driver=wda.UsBClient(udid=self.udid,port=8100,wda_bundle_id=self.wda_bundle_id)

even through wda_bundle_id is not using now. @copilot

Co-authored-by: codeskyblue <3281689+codeskyblue@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Oct 30, 2025

try to support

driver=wda.UsBClient(udid=self.udid,port=8100,wda_bundle_id=self.wda_bundle_id)

...

Added wda_bundle_id parameter to USBClient.__init__() with signature: USBClient(udid: str = "", port: int = 8100, wda_bundle_id: str = None). The parameter is ready for future use. (8e82397)

Copilot AI changed the title Fix unreachable exception in USBClient initialization Fix unreachable exception in USBClient initialization and add wda_bundle_id parameter Oct 30, 2025
@codeskyblue codeskyblue marked this pull request as ready for review October 30, 2025 09:35
Comment thread wda/__init__.py Outdated
if self.is_ready():
return

if not self.wait_ready(timeout=20, noprint=True):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to change the original logic, just comment raise RuntimeError line

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

新版本代码漏检以及建议

2 participants