From e44eba453cdad8afb5efb46c42bd192fb9a04763 Mon Sep 17 00:00:00 2001 From: Shuang Wu Date: Tue, 19 Sep 2023 20:42:50 -0500 Subject: [PATCH] feat: add back Python 3.7 support We do not test the code against Python 3.7 runtime so the support might break in the future release. Fix #292 --- python/scripts/utils/__init__.py | 12 ++++++++---- python/tests/__init__.py | 10 +++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/python/scripts/utils/__init__.py b/python/scripts/utils/__init__.py index eedb57f..0b7edda 100644 --- a/python/scripts/utils/__init__.py +++ b/python/scripts/utils/__init__.py @@ -5,9 +5,12 @@ QT_DEPENDENCY_ARG = "vscode_extension_qt_dependency" -SupportedQtDependencies = typing.Optional[ - typing.Literal["PySide6", "PySide2", "PyQt6", "PyQt5"] -] +if sys.version_info < (3, 8): + SupportedQtDependencies = typing.Optional[str] # pragma: no cover +else: + SupportedQtDependencies = typing.Optional[ + typing.Literal["PySide6", "PySide2", "PyQt6", "PyQt5"] + ] def is_installed(name: str) -> bool: @@ -21,7 +24,8 @@ def parse_qt_dependency() -> SupportedQtDependencies: required=False, ) - if dep := vars(parser.parse_known_args()[0])[QT_DEPENDENCY_ARG]: + dep = vars(parser.parse_known_args()[0])[QT_DEPENDENCY_ARG] + if dep is not None: sys.argv.remove(f"--{QT_DEPENDENCY_ARG}") sys.argv.remove(dep) diff --git a/python/tests/__init__.py b/python/tests/__init__.py index 05048fa..33bf97d 100644 --- a/python/tests/__init__.py +++ b/python/tests/__init__.py @@ -1,6 +1,7 @@ import os import platform import subprocess +import sys import typing from scripts.utils import QT_DEPENDENCY_ARG, SupportedQtDependencies @@ -11,9 +12,12 @@ ASSETS_DIR = os.path.join(TESTS_DIR, "assets") -SupportedScripts = typing.Literal[ - "designer", "qml", "qmlls", "rcc", "uic", "lupdate", "linguist", "lrelease" -] +if sys.version_info < (3, 8): + SupportedScripts = str +else: + SupportedScripts = typing.Literal[ + "designer", "qml", "qmlls", "rcc", "uic", "lupdate", "linguist", "lrelease" + ] def filter_available_qt_dependencies(