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 <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230605063142.6843-1-newbyte@postmarketos.org%3E
This commit is contained in:
Newbyte 2023-06-05 08:31:43 +02:00 committed by Oliver Smith
parent 09870a46a0
commit c6a8a2614d
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 2 additions and 1 deletions

View File

@ -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.