mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
Use optional[] for python compat
This commit is contained in:
parent
2d1403330b
commit
a5cb6919fb
1 changed files with 4 additions and 2 deletions
|
@ -5,6 +5,7 @@ import argparse
|
|||
import tempfile
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from git import Repo
|
||||
|
||||
|
||||
|
@ -24,7 +25,7 @@ class TemporaryPath(Path):
|
|||
return Path(*pathsegments)
|
||||
|
||||
|
||||
APPS_REPO_DIR: TemporaryPath | None = None
|
||||
APPS_REPO_DIR: Optional[TemporaryPath] = None
|
||||
|
||||
def add_args(parser: argparse.ArgumentParser, required: bool = False, allow_temp: bool = True) -> None:
|
||||
env_apps_dir_str = os.environ.get("YNH_APPS_DIR")
|
||||
|
@ -37,7 +38,7 @@ def add_args(parser: argparse.ArgumentParser, required: bool = False, allow_temp
|
|||
repo_group.add_argument("-d", "--apps-dir", type=Path, help="Path to an existing 'apps' repository", default=env_apps_dir)
|
||||
|
||||
|
||||
def from_args(args: argparse.Namespace | None) -> Path:
|
||||
def from_args(args: Optional[argparse.Namespace]) -> Path:
|
||||
global APPS_REPO_DIR
|
||||
if APPS_REPO_DIR is not None:
|
||||
return APPS_REPO_DIR
|
||||
|
@ -45,6 +46,7 @@ def from_args(args: argparse.Namespace | None) -> Path:
|
|||
assert args is not None
|
||||
if args.apps_dir is not None:
|
||||
APPS_REPO_DIR = args.apps_dir
|
||||
assert APPS_REPO_DIR is not None
|
||||
return APPS_REPO_DIR
|
||||
|
||||
if args.apps_repo is not None:
|
||||
|
|
Loading…
Add table
Reference in a new issue