Skip to content

Commit

Permalink
feat: support Python 3.7+
Browse files Browse the repository at this point in the history
Fix #292
  • Loading branch information
seanwu1105 committed Apr 6, 2023
1 parent 289e02b commit e8429d7
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nodejs 18.14.2
python 3.10.9
python 3.7.16
2 changes: 1 addition & 1 deletion python/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ persistent=yes

# Minimum Python version to use for version dependent checks. Will default to
# the version used to run pylint.
py-version=3.10
py-version=3.7

# Discover python modules and packages in the file system subtree.
recursive=no
Expand Down
2 changes: 1 addition & 1 deletion python/.tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python 3.10.9
python 3.7.16
133 changes: 126 additions & 7 deletions python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ description = "Scripts to communicate between the extension and Qt for Python li
authors = ["Shuang Wu <seanwu1105@gmail.com>"]

[tool.poetry.dependencies]
python = "~3.10"
python = "~3.7.2"
pyside6 = "^6.4.2"
pyqt6 = "^6.4.0"
pyside2 = { version = "^5.15.2.1", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'" }
pyqt5 = { version = "^5.15.7", markers = "sys_platform != 'darwin' or platform_machine != 'arm64'" }
typing-extensions = "^4.5.0"

[tool.poetry.group.dev.dependencies]
pylint = "^2.14.5"
Expand Down
7 changes: 5 additions & 2 deletions python/scripts/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import sys
import typing

import typing_extensions # Remove after dropping Python 3.7

QT_DEPENDENCY_ARG = "vscode_extension_qt_dependency"

SupportedQtDependencies = typing.Optional[
typing.Literal["PySide6", "PySide2", "PyQt6", "PyQt5"]
typing_extensions.Literal["PySide6", "PySide2", "PyQt6", "PyQt5"]
]


Expand All @@ -21,7 +23,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)

Expand Down
10 changes: 6 additions & 4 deletions python/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import subprocess
import typing

import typing_extensions

from scripts.utils import QT_DEPENDENCY_ARG, SupportedQtDependencies

TESTS_DIR = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -11,22 +13,22 @@

ASSETS_DIR = os.path.join(TESTS_DIR, "assets")

SupportedScripts = typing.Literal[
SupportedScripts = typing_extensions.Literal[
"designer", "qml", "qmlls", "rcc", "uic", "lupdate", "linguist", "lrelease"
]


def filter_available_qt_dependencies(
deps: list[SupportedQtDependencies],
) -> list[SupportedQtDependencies]:
deps: typing.List[SupportedQtDependencies],
) -> typing.List[SupportedQtDependencies]:
if platform.system() == "Darwin" and platform.machine() == "arm64":
return [None] + list(filter(lambda d: d not in ("PySide2", "PyQt5"), deps))
return [None] + deps


def invoke_script(
name: SupportedScripts,
args: list[str],
args: typing.List[str],
qt_dependency: SupportedQtDependencies,
):
if qt_dependency is not None:
Expand Down

0 comments on commit e8429d7

Please sign in to comment.