diff options
| author | Adrian Herrmann <adrian.herrmann@qt.io> | 2024-06-06 10:59:31 +0200 |
|---|---|---|
| committer | Adrian Herrmann <adrian.herrmann@qt.io> | 2024-06-20 16:10:46 +0000 |
| commit | ba2582125f6c9d470d3a5f4e1e61666de9101e0e (patch) | |
| tree | cb04e0b4a90e02e0d6026309447fbcf08a8e00a0 /sources/pyside-tools/project/utils.py | |
| parent | 7bb9c0e2f81ec474bf98690b4f90f195a6ea27c8 (diff) | |
Use modern typing syntax
We can already use the modern typing syntax introduced with Python 3.10
in 3.9 via future statement definitions, even before we raise the
minimum Python version to 3.10.
Note that direct expressions with "|" don't work yet.
Task-number: PYSIDE-2786
Change-Id: Ie36c140fc960328322502ea29cf6868805a7c558
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside-tools/project/utils.py')
| -rw-r--r-- | sources/pyside-tools/project/utils.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sources/pyside-tools/project/utils.py b/sources/pyside-tools/project/utils.py index 4c1e1d925..a2d91375b 100644 --- a/sources/pyside-tools/project/utils.py +++ b/sources/pyside-tools/project/utils.py @@ -5,12 +5,11 @@ from __future__ import annotations import sys import subprocess from pathlib import Path -from typing import List, Dict, Optional from . import QTPATHS_CMD, PROJECT_FILE_SUFFIX, ClOptions -def run_command(command: List[str], cwd: str = None, ignore_fail: bool = False): +def run_command(command: list[str], cwd: str = None, ignore_fail: bool = False): """Run a command observing quiet/dry run""" cloptions = ClOptions() if not cloptions.quiet or cloptions.dry_run: @@ -21,7 +20,7 @@ def run_command(command: List[str], cwd: str = None, ignore_fail: bool = False): sys.exit(ex) -def requires_rebuild(sources: List[Path], artifact: Path) -> bool: +def requires_rebuild(sources: list[Path], artifact: Path) -> bool: """Returns whether artifact needs to be rebuilt depending on sources""" if not artifact.is_file(): return True @@ -59,10 +58,10 @@ def package_dir() -> Path: return Path(__file__).resolve().parents[2] -_qtpaths_info: Dict[str, str] = {} +_qtpaths_info: dict[str, str] = {} -def qtpaths() -> Dict[str, str]: +def qtpaths() -> dict[str, str]: """Run qtpaths and return a dict of values.""" global _qtpaths_info if not _qtpaths_info: @@ -74,7 +73,7 @@ def qtpaths() -> Dict[str, str]: return _qtpaths_info -_qt_metatype_json_dir: Optional[Path] = None +_qt_metatype_json_dir: Path | None = None def qt_metatype_json_dir() -> Path: @@ -96,7 +95,7 @@ def qt_metatype_json_dir() -> Path: return _qt_metatype_json_dir -def resolve_project_file(cmdline: str) -> Optional[Path]: +def resolve_project_file(cmdline: str) -> Path | None: """Return the project file from the command line value, either from the file argument or directory""" project_file = Path(cmdline).resolve() if cmdline else Path.cwd() |
