1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-02-03 13:47:14 +03:00

Some minor type fixes for mypy

This commit is contained in:
Adolfo Gómez García 2024-07-05 19:32:44 +02:00
parent 2c8ef0cbe9
commit 28ed59e185
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
3 changed files with 8 additions and 8 deletions

View File

@ -54,25 +54,25 @@ def detect_os(
# First, try to detect from Sec-Ch-Ua-Platform
# Remember all Sec... headers are only available on secure connections
sec_ch_ua_platform = headers.get('Sec-Ch-Ua-Platform')
found = types.os.KnownOS.UNKNOWN
found_os = types.os.KnownOS.UNKNOWN
if sec_ch_ua_platform is not None:
# Strip initial and final " chars if present
sec_ch_ua_platform = sec_ch_ua_platform.strip('"')
for os in consts.os.KNOWN_OS_LIST:
if sec_ch_ua_platform in os.value:
found = os
found_os = os
break
else: # Try to detect from User-Agent
ual = ua.lower()
for os in consts.os.KNOWN_OS_LIST:
if os.os_name().lower() in ual:
found = os
found_os = types.os.KnownOS(os)
break
# If we found a known OS, store it
if found != types.os.KnownOS.UNKNOWN:
res.os = found
if found_os != types.os.KnownOS.UNKNOWN:
res.os = found_os
# Try to detect browser from Sec-Ch-Ua first
sec_ch_ua = headers.get('Sec-Ch-Ua')
@ -83,7 +83,7 @@ def detect_os(
break
else:
# Try to detect browser from User-Agent
found = None
found: 'None|typing.Match[str]' = None
browser_type = None
for browser_type, rules in consts.os.BROWSER_RULES.items():

View File

@ -192,7 +192,7 @@ class XenClient: # pylint: disable=too-many-public-methods
# We recalculate here url, because we can "switch host" on any moment
self._url = self._protocol + self._host + ':' + self._port
transport = None
transport: 'SafeTimeoutTransport|TimeoutTransport|None' = None
if self._use_ssl:
context = security.create_client_sslcontext(verify=self._verify_ssl)

View File

@ -114,7 +114,7 @@ class XenRetryableError(XenException, exceptions.RetryableError):
@contextlib.contextmanager
def translator():
def translator() -> typing.Generator[None, None, None]:
try:
yield
except XenException: