remove '*' indicating keyword-only arguments

they are kind of unnecessary and
cause a non-insignificant function call overhead (~10%)
This commit is contained in:
Mike Fährmann
2023-05-02 22:16:58 +02:00
parent 0c46758a93
commit 076380e079
4 changed files with 15 additions and 16 deletions

View File

@@ -119,7 +119,7 @@ def clear():
_config.clear()
def get(path, key, default=None, *, conf=_config):
def get(path, key, default=None, conf=_config):
"""Get the value of property 'key' or a default value"""
try:
for p in path:
@@ -129,7 +129,7 @@ def get(path, key, default=None, *, conf=_config):
return default
def interpolate(path, key, default=None, *, conf=_config):
def interpolate(path, key, default=None, conf=_config):
"""Interpolate the value of 'key'"""
if key in conf:
return conf[key]
@@ -143,7 +143,7 @@ def interpolate(path, key, default=None, *, conf=_config):
return default
def interpolate_common(common, paths, key, default=None, *, conf=_config):
def interpolate_common(common, paths, key, default=None, conf=_config):
"""Interpolate the value of 'key'
using multiple 'paths' along a 'common' ancestor
"""
@@ -175,7 +175,7 @@ def interpolate_common(common, paths, key, default=None, *, conf=_config):
return default
def accumulate(path, key, *, conf=_config):
def accumulate(path, key, conf=_config):
"""Accumulate the values of 'key' along 'path'"""
result = []
try:
@@ -194,7 +194,7 @@ def accumulate(path, key, *, conf=_config):
return result
def set(path, key, value, *, conf=_config):
def set(path, key, value, conf=_config):
"""Set the value of property 'key' for this session"""
for p in path:
try:
@@ -204,7 +204,7 @@ def set(path, key, value, *, conf=_config):
conf[key] = value
def setdefault(path, key, value, *, conf=_config):
def setdefault(path, key, value, conf=_config):
"""Set the value of property 'key' if it doesn't exist"""
for p in path:
try:
@@ -214,7 +214,7 @@ def setdefault(path, key, value, *, conf=_config):
return conf.setdefault(key, value)
def unset(path, key, *, conf=_config):
def unset(path, key, conf=_config):
"""Unset the value of property 'key'"""
try:
for p in path:

View File

@@ -412,18 +412,17 @@ class ChromeCookieDecryptor:
raise NotImplementedError("Must be implemented by sub classes")
def get_cookie_decryptor(browser_root, browser_keyring_name, *, keyring=None):
def get_cookie_decryptor(browser_root, browser_keyring_name, keyring=None):
if sys.platform in ("win32", "cygwin"):
return WindowsChromeCookieDecryptor(browser_root)
elif sys.platform == "darwin":
return MacChromeCookieDecryptor(browser_keyring_name)
else:
return LinuxChromeCookieDecryptor(
browser_keyring_name, keyring=keyring)
return LinuxChromeCookieDecryptor(browser_keyring_name, keyring)
class LinuxChromeCookieDecryptor(ChromeCookieDecryptor):
def __init__(self, browser_keyring_name, *, keyring=None):
def __init__(self, browser_keyring_name, keyring=None):
self._v10_key = self.derive_key(b"peanuts")
password = _get_linux_keyring_password(browser_keyring_name, keyring)
self._v11_key = None if password is None else self.derive_key(password)

View File

@@ -106,7 +106,7 @@ class Extractor():
values[:0] = config.accumulate((self.subcategory,), key, conf=conf)
return values
def request(self, url, *, method="GET", session=None,
def request(self, url, method="GET", session=None,
retries=None, retry_codes=None, encoding=None,
fatal=True, notfound=None, **kwargs):
if session is None:
@@ -180,7 +180,7 @@ class Extractor():
raise exception.HttpError(msg, response)
def wait(self, *, seconds=None, until=None, adjust=1.0,
def wait(self, seconds=None, until=None, adjust=1.0,
reason="rate limit reset"):
now = time.time()
@@ -371,7 +371,7 @@ class Extractor():
except OSError as exc:
self.log.warning("cookies: %s", exc)
def _update_cookies(self, cookies, *, domain=""):
def _update_cookies(self, cookies, domain=""):
"""Update the session's cookiejar with 'cookies'"""
if isinstance(cookies, dict):
self._update_cookies_dict(cookies, domain or self.cookiedomain)
@@ -391,7 +391,7 @@ class Extractor():
for name, value in cookiedict.items():
setcookie(name, value, domain=domain)
def _check_cookies(self, cookienames, *, domain=None):
def _check_cookies(self, cookienames, domain=None):
"""Check if all 'cookienames' are in the session's cookiejar"""
if not self._cookiejar:
return False

View File

@@ -134,7 +134,7 @@ class OAuthBase(Extractor):
def _oauth2_authorization_code_grant(
self, client_id, client_secret, default_id, default_secret,
auth_url, token_url, *, scope="read", duration="permanent",
auth_url, token_url, scope="read", duration="permanent",
key="refresh_token", auth=True, cache=None, instance=None):
"""Perform an OAuth2 authorization code grant"""