pmb: Replace list(...)[0] with next(iter(...)) (MR 2525)

See https://docs.astral.sh/ruff/rules/unnecessary-iterable-allocation-for-first-element
This commit is contained in:
Newbyte 2025-01-08 00:05:29 +01:00 committed by Oliver Smith
parent 752c1df039
commit c2787aa76f
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 3 additions and 3 deletions

View file

@ -399,7 +399,7 @@ def ask_for_device_kernel(config: Config, device: str) -> str:
# Get default # Get default
default = config.kernel default = config.kernel
if default not in kernels: if default not in kernels:
default = list(kernels.keys())[0] default = next(iter(kernels.keys()))
# Ask for kernel (extra message when downstream and upstream are available) # Ask for kernel (extra message when downstream and upstream are available)
logging.info("Which kernel do you want to use with your device?") logging.info("Which kernel do you want to use with your device?")

View file

@ -27,7 +27,7 @@ def package_provider(
# 1. Only one provider # 1. Only one provider
logging.verbose(f"{pkgname}: provided by: {', '.join(providers)}") logging.verbose(f"{pkgname}: provided by: {', '.join(providers)}")
if len(providers) == 1: if len(providers) == 1:
return list(providers.values())[0] return next(iter(providers.values()))
# 2. Provider with the same package name # 2. Provider with the same package name
if pkgname in providers: if pkgname in providers:
@ -66,7 +66,7 @@ def package_provider(
# 6. Pick the provider(s) with the highest priority # 6. Pick the provider(s) with the highest priority
providers = pmb.parse.apkindex.provider_highest_priority(providers, pkgname) providers = pmb.parse.apkindex.provider_highest_priority(providers, pkgname)
if len(providers) == 1: if len(providers) == 1:
return list(providers.values())[0] return next(iter(providers.values()))
# 7. Pick the shortest provider. (Note: Normally apk would fail here!) # 7. Pick the shortest provider. (Note: Normally apk would fail here!)
return pmb.parse.apkindex.provider_shortest(providers, pkgname) return pmb.parse.apkindex.provider_shortest(providers, pkgname)