diff --git a/nvchecker/core.py b/nvchecker/core.py index e753eeb..e74a88a 100644 --- a/nvchecker/core.py +++ b/nvchecker/core.py @@ -57,7 +57,7 @@ def add_common_arguments(parser: argparse.ArgumentParser) -> None: parser.add_argument('-c', '--file', metavar='FILE', type=str, default=default_config, - help='software version configuration file [default: %s]' % default_config) + help=f'software version configuration file [default: {default_config}]') def process_common_arguments(args: argparse.Namespace) -> bool: '''return True if should stop''' @@ -94,7 +94,7 @@ def process_common_arguments(args: argparse.Namespace) -> bool: if args.version: progname = os.path.basename(sys.argv[0]) - print('%s v%s' % (progname, __version__)) + print(f'{progname} v{__version__}') return True return False diff --git a/nvchecker/ctxvars.py b/nvchecker/ctxvars.py index 2f5b49a..e9daf71 100644 --- a/nvchecker/ctxvars.py +++ b/nvchecker/ctxvars.py @@ -8,7 +8,7 @@ from typing import Optional from . import __version__ -DEFAULT_USER_AGENT = 'lilydjwg/nvchecker %s' % __version__ +DEFAULT_USER_AGENT = f'lilydjwg/nvchecker {__version__}' tries = ContextVar('tries', default=1) proxy: ContextVar[Optional[str]] = ContextVar('proxy', default=None) diff --git a/nvchecker/slogconf.py b/nvchecker/slogconf.py index c0db526..fefb86e 100644 --- a/nvchecker/slogconf.py +++ b/nvchecker/slogconf.py @@ -27,7 +27,7 @@ def _console_msg(event): msg = evt if 'name' in event: - msg = '%s: %s' % (event['name'], msg) + msg = f"{event['name']}: {msg}" del event['name'] event['msg'] = msg diff --git a/nvchecker_source/gitea.py b/nvchecker_source/gitea.py index 17cb558..0ff3a93 100644 --- a/nvchecker_source/gitea.py +++ b/nvchecker_source/gitea.py @@ -36,7 +36,7 @@ async def get_version( # Set private token if token exists. headers = {} if token: - headers["Authorization"] = 'token %s' % token + headers["Authorization"] = f'token {token}' data = await cache.get_json(url, headers = headers) if use_max_tag: diff --git a/nvchecker_source/github.py b/nvchecker_source/github.py index 36414b7..0920d54 100644 --- a/nvchecker_source/github.py +++ b/nvchecker_source/github.py @@ -46,7 +46,7 @@ async def get_latest_tag(key: Tuple[str, str, str]) -> str: repo, query, token = key owner, reponame = repo.split('/') headers = { - 'Authorization': 'bearer %s' % token, + 'Authorization': f'bearer {token}', 'Content-Type': 'application/json', } q = QUERY_LATEST_TAG.format( @@ -109,7 +109,7 @@ async def get_version_real( 'Accept': 'application/vnd.github.quicksilver-preview+json', } if token: - headers['Authorization'] = 'token %s' % token + headers['Authorization'] = f'token {token}' data = await cache.get_json(url, headers = headers) @@ -140,9 +140,8 @@ def check_ratelimit(exc, name): n = int(res.headers.get('X-RateLimit-Remaining', -1)) if n == 0: reset = int(res.headers.get('X-RateLimit-Reset')) - logger.error('rate limited, resetting at %s. ' - 'Or get an API token to increase the allowance if not yet' - % time.ctime(reset), + logger.error(f'rate limited, resetting at {time.ctime(reset)}. ' + 'Or get an API token to increase the allowance if not yet', name = name, reset = reset) else: diff --git a/scripts/maintained_in_aur b/scripts/maintained_in_aur index c351996..37dff6b 100755 --- a/scripts/maintained_in_aur +++ b/scripts/maintained_in_aur @@ -9,10 +9,10 @@ import json import urllib.request def main(user): - url = 'https://aur.archlinux.org/rpc.php?type=msearch&arg=' + user + url = f'https://aur.archlinux.org/rpc.php?type=msearch&arg={user}' res = urllib.request.urlopen(url) if res.status != 200: - sys.exit('Error: %d %s' % (res.status, res.reason)) + sys.exit(f'Error: {res.status} {res.reason}') d = res.read().decode('utf-8') d = json.loads(d) print('\n'.join(sorted(pkg['Name'] for pkg in d['results'])))