From c6a8a2614d34148176a737887dbb56d66bdedcb6 Mon Sep 17 00:00:00 2001 From: Newbyte Date: Mon, 5 Jun 2023 08:31:43 +0200 Subject: [PATCH] pmb.config.sudo: Use type union compatible with Python 3.7 The Type | OtherType syntax for writing unions was introduced in Python 3.10. We want to support Python 3.7, so use an Optional type hint instead which declares the same thing and is supported by 3.7. Fixes: d31313f7 ("Don't use 'sudo' when running as root") Reviewed-by: Luca Weiss Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230605063142.6843-1-newbyte@postmarketos.org%3E --- pmb/config/sudo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pmb/config/sudo.py b/pmb/config/sudo.py index 1e227534..baa5963e 100644 --- a/pmb/config/sudo.py +++ b/pmb/config/sudo.py @@ -3,10 +3,11 @@ import os import shutil from functools import lru_cache +from typing import Optional @lru_cache() -def which_sudo() -> str | None: +def which_sudo() -> Optional[str]: """Returns a command required to run commands as root, if any. Find whether sudo or doas is installed for commands that require root.