Skip to content

Commit 99e0f9f

Browse files
committed
refactor: use early return in setup proxy method
1 parent daa8712 commit 99e0f9f

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

pydoll/browser/chromium/base.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -656,22 +656,24 @@ async def _configure_proxy(
656656
self, private_proxy: bool, proxy_credentials: tuple[Optional[str], Optional[str]]
657657
):
658658
"""Setup proxy authentication handling if needed."""
659-
if private_proxy:
660-
await self.enable_fetch_events(handle_auth_requests=True)
661-
await self.on(
662-
FetchEvent.REQUEST_PAUSED,
663-
self._continue_request_callback,
664-
temporary=True,
665-
)
666-
await self.on(
667-
FetchEvent.AUTH_REQUIRED,
668-
partial(
669-
self._continue_request_with_auth_callback,
670-
proxy_username=proxy_credentials[0],
671-
proxy_password=proxy_credentials[1],
672-
),
673-
temporary=True,
674-
)
659+
if not private_proxy:
660+
return
661+
662+
await self.enable_fetch_events(handle_auth_requests=True)
663+
await self.on(
664+
FetchEvent.REQUEST_PAUSED,
665+
self._continue_request_callback,
666+
temporary=True,
667+
)
668+
await self.on(
669+
FetchEvent.AUTH_REQUIRED,
670+
partial(
671+
self._continue_request_with_auth_callback,
672+
proxy_username=proxy_credentials[0],
673+
proxy_password=proxy_credentials[1],
674+
),
675+
temporary=True,
676+
)
675677

676678
@staticmethod
677679
def _is_valid_tab(target: TargetInfo) -> bool:

0 commit comments

Comments
 (0)