From 365d47a8438dea0d7f95dc5bd609d48f9b3604ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 12 Jul 2022 11:04:23 +0200 Subject: [PATCH] Use walrus more It was already used in other places, so this doesn't change much. Walrus was added in 3.8, so drop 3.7 from the compat list. --- rust2rpm/__main__.py | 7 ++----- rust2rpm/util.py | 6 ++---- setup.py | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index 81610f3..bae1182 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -62,8 +62,7 @@ def read_os_release(): line = line.rstrip() if not line or line.startswith('#'): continue - m = re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line) - if m: + if m := re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line): name, val = m.groups() if val and val[0] in '"\'': val = ast.literal_eval(val) @@ -517,9 +516,7 @@ def main(): if args.target in {"fedora"} and args.existence_check and not os.path.exists(spec_file): # No specfile, so this is probably a new package - package_info = get_package_info(pkg_name) - - if package_info: + if package_info := get_package_info(pkg_name): if args.suffix: print(f"Versions {args.suffix}.* of the crate '{metadata.name}' are already") print(f"packaged for Fedora: {package_info['full_url']}") diff --git a/rust2rpm/util.py b/rust2rpm/util.py index fe6916b..f15941a 100644 --- a/rust2rpm/util.py +++ b/rust2rpm/util.py @@ -54,13 +54,11 @@ def detect_packager(): return packager # If we're detecting packager identity through rpmdev-packager... - rpmdev_packager = shutil.which('rpmdev-packager') - if rpmdev_packager is not None: + if rpmdev_packager := shutil.which('rpmdev-packager'): return subprocess.check_output(rpmdev_packager, text=True).strip() # If we're detecting packager identity through git configuration... - git = shutil.which('git') - if git is not None: + if git := shutil.which('git'): name = subprocess.check_output([git, 'config', 'user.name'], text=True).strip() email = subprocess.check_output([git, 'config', 'user.email'], text=True).strip() return f'{name} <{email}>' diff --git a/setup.py b/setup.py index 64aecb8..00ccfff 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,6 @@ ARGS = dict( "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10",