From b3a7a972c90a855a0845313e8ed1cf687d0cc471 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 24 Oct 2023 00:15:58 -0400 Subject: [PATCH] fix compatibility with Python 3.7 (#38) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 7 ++++++- dargs/dargs.py | 7 ++++++- pyproject.toml | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c88ba61..4d74ee5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,12 +7,17 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + python_version: + - "3" + - "3.7" steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3 + python-version: ${{ matrix.python_version }} - run: pip install .[test] coverage - name: Test run: coverage run --source=./dargs -m unittest -v && coverage report diff --git a/dargs/dargs.py b/dargs/dargs.py index 38bfdf3..dc70b0d 100644 --- a/dargs/dargs.py +++ b/dargs/dargs.py @@ -24,7 +24,12 @@ from copy import deepcopy from enum import Enum from textwrap import indent -from typing import Any, Callable, Dict, Iterable, List, Optional, Union, get_origin +from typing import Any, Callable, Dict, Iterable, List, Optional, Union + +try: + from typing import get_origin +except ImportError: + from typing_extensions import get_origin import typeguard diff --git a/pyproject.toml b/pyproject.toml index bd31a2f..506180f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ classifiers = [ ] dependencies = [ "typeguard>=3", + 'typing_extensions; python_version < "3.8"', ] requires-python = ">=3.7" readme = "README.md"