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:
parent
2c8ef0cbe9
commit
28ed59e185
@ -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():
|
||||
|
@ -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)
|
||||
|
@ -114,7 +114,7 @@ class XenRetryableError(XenException, exceptions.RetryableError):
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def translator():
|
||||
def translator() -> typing.Generator[None, None, None]:
|
||||
try:
|
||||
yield
|
||||
except XenException:
|
||||
|
Loading…
x
Reference in New Issue
Block a user