From d3df858b440c62ded675c508682884e3be1f322f Mon Sep 17 00:00:00 2001 From: Dor-bl <59066376+Dor-bl@users.noreply.github.com> Date: Sun, 11 Oct 2026 08:00:51 +0000 Subject: [PATCH 1/2] refactor: optimize direct connect capability string construction Replace string concatenation in loop with f-string formatting in _update_command_executor in appium/webdriver/webdriver.py. Also remove unnecessary set(self.caps) conversion when checking capability subset. --- appium/webdriver/webdriver.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 09d17094..57991598 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -314,10 +314,14 @@ def _update_command_executor(self, keep_alive: bool) -> None: if not self.caps: raise ValueError('Driver capabilities must be defined') - if not {direct_protocol, direct_host, direct_port, direct_path}.issubset(set(self.caps)): - message = 'Direct connect capabilities from server were:\n' - for key in [direct_protocol, direct_host, direct_port, direct_path]: - message += f"{key}: '{self.caps.get(key, '')}' " + if not {direct_protocol, direct_host, direct_port, direct_path}.issubset(self.caps): + message = ( + 'Direct connect capabilities from server were:\n' + f"{direct_protocol}: '{self.caps.get(direct_protocol, '')}' " + f"{direct_host}: '{self.caps.get(direct_host, '')}' " + f"{direct_port}: '{self.caps.get(direct_port, '')}' " + f"{direct_path}: '{self.caps.get(direct_path, '')}' " + ) logger.debug(message) return From 4dc6d5d0c0d811c90f829c9ea1fb68d7719b41e1 Mon Sep 17 00:00:00 2001 From: Dor-bl <59066376+Dor-bl@users.noreply.github.com> Date: Sun, 11 Oct 2026 08:44:51 +0000 Subject: [PATCH 2/2] refactor: optimize direct connect capability string construction Replace string concatenation in loop with f-string formatting in _update_command_executor in appium/webdriver/webdriver.py. Also remove unnecessary set(self.caps) conversion when checking capability subset.