From d4e3cd347b4d38f9e91c0203c2d3d030705c56bd Mon Sep 17 00:00:00 2001 From: c-bata Date: Tue, 27 Oct 2020 03:12:14 +0900 Subject: [PATCH] Use typing_extensions --- .github/workflows/python-tests.yml | 7 +++++-- optuna_dashboard/serializer.py | 7 ++++++- setup.py | 12 ++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 1f7e3331..3ac673f8 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -25,12 +25,15 @@ jobs: - run: mypy . test: runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] steps: - uses: actions/checkout@v2 - - name: Set up Python + - name: Setup Python${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: ${{ matrix.python-version }} architecture: x64 - name: Install dependencies run: pip install --progress-bar off . diff --git a/optuna_dashboard/serializer.py b/optuna_dashboard/serializer.py index 6646cfb4..de733a4b 100644 --- a/optuna_dashboard/serializer.py +++ b/optuna_dashboard/serializer.py @@ -1,9 +1,14 @@ import json -from typing import Any, Dict, List, TypedDict +from typing import Any, Dict, List from optuna.study import StudySummary from optuna.trial import FrozenTrial +try: + from typing import TypedDict +except: + from typing_extensions import TypedDict + Attribute = TypedDict( "Attribute", diff --git a/setup.py b/setup.py index ad83d493..ff079c35 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ import os +import sys import types - +from typing import List from setuptools import setup, find_packages from importlib.machinery import SourceFileLoader @@ -22,6 +23,13 @@ def get_version() -> int: return getattr(target_module, "__version__") +def get_install_requires() -> List[str]: + deps = ["optuna", "bottle"] + if sys.version_info[:2] < (3, 8): + deps.append("typing-extensions") + return deps + + setup( name="optuna-dashboard", version=get_version(), @@ -32,7 +40,7 @@ setup( author_email="m.shibata1020@gmail.com", url="https://github.com/c-bata/optuna-dashboard", packages=find_packages(), - install_requires=["optuna", "bottle"], + install_requires=get_install_requires(), extras_require={ "lint": ["black", "flake8", "mypy"], "release": ["wheel", "twine"],