Skip to content

Commit

Permalink
Add typing_extensions dependency on python < 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
veghdev committed Aug 15, 2023
1 parent 8926117 commit 9f997d2
Show file tree
Hide file tree
Showing 9 changed files with 395 additions and 244 deletions.
240 changes: 178 additions & 62 deletions package-lock.json

Large diffs are not rendered by default.

346 changes: 179 additions & 167 deletions pdm.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ authors = [
readme = "README.md"
requires-python = ">=3.6"
dependencies = [
"typing_extensions ; python_version < '3.8'",
"IPython",
"jsonschema",
]
Expand Down
7 changes: 3 additions & 4 deletions src/ipyvizzu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
* [DisplayTemplate][ipyvizzu.template.DisplayTemplate]
"""

import sys
import warnings

from .chart import Chart
Expand All @@ -70,7 +69,7 @@
from .template import ChartProperty, DisplayTarget, DisplayTemplate
from .event import EventHandler

from .__version__ import __version__
from .__version__ import __version__, PYENV

__all__ = [
"Chart",
Expand Down Expand Up @@ -103,8 +102,8 @@
]


if sys.version_info < (3, 7):
# TODO: remove once support for Python 3.6 is dropped
# TODO: remove once support for Python 3.6 is dropped
if PYENV < (3, 7):
warnings.warn(
"Python 3.6 support will be dropped in future versions.",
FutureWarning,
Expand Down
5 changes: 5 additions & 0 deletions src/ipyvizzu/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""A module for storing version number."""

import sys


__version__ = "0.15.0"

PYENV = sys.version_info
11 changes: 10 additions & 1 deletion src/ipyvizzu/data/converters/pandas/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
"""

from typing import Any, Callable, Sequence
from typing_extensions import Protocol, runtime_checkable

from ipyvizzu.__version__ import PYENV


if PYENV >= (3, 8):
from typing import Protocol, runtime_checkable
else:
# TODO: remove once support for Python 3.7 is dropped
# pylint: disable=duplicate-code
from typing_extensions import Protocol, runtime_checkable # type: ignore


@runtime_checkable
Expand Down
11 changes: 10 additions & 1 deletion src/ipyvizzu/data/converters/spark/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
"""

from typing import Any, Callable, Sequence
from typing_extensions import Protocol, runtime_checkable

from ipyvizzu.__version__ import PYENV


if PYENV >= (3, 8):
from typing import Protocol, runtime_checkable
else:
# TODO: remove once support for Python 3.7 is dropped
# pylint: disable=duplicate-code
from typing_extensions import Protocol, runtime_checkable # type: ignore


@runtime_checkable
Expand Down
5 changes: 3 additions & 2 deletions tests/test_docs/tutorial/test_data.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring

from pathlib import Path
import sys
import unittest

import numpy as np
import pandas as pd
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, StructField, StringType, IntegerType

from ipyvizzu.__version__ import PYENV

from tests.test_data import DataWithAssets


Expand Down Expand Up @@ -70,7 +71,7 @@ def test_with_csv(self) -> None:
)

# TODO: remove decorator once support for Python 3.6 is dropped
@unittest.skipUnless(sys.version_info >= (3, 7), "at least Python 3.7 is required")
@unittest.skipUnless(PYENV >= (3, 7), "at least Python 3.7 is required")
def test_with_xlsx(self) -> None:
df = pd.read_excel(self.docs_dir / "music_data.xlsx")
self.data.add_df(df)
Expand Down
13 changes: 6 additions & 7 deletions tests/test_fugue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@
from contextlib import redirect_stdout
import io
import pathlib
import sys
import unittest

import pandas as pd

from ipyvizzu.__version__ import PYENV

from tests.utils.normalizer import Normalizer


if sys.version_info >= (3, 7):
# TODO: remove once support for Python 3.6 is dropped
if PYENV >= (3, 7):
import fugue.api as fa
import ipyvizzu.integrations.fugue # register the extension # pylint: disable=unused-import
else:
# TODO: remove once support for Python 3.6 is dropped
pass


class TestFugue(unittest.TestCase):
# TODO: remove decorator once support for Python 3.6 is dropped
@unittest.skipUnless(sys.version_info >= (3, 7), "at least Python 3.7 is required")
@unittest.skipUnless(PYENV >= (3, 7), "at least Python 3.7 is required")
def test_fugue_extension_preset(self) -> None:
ref = pathlib.Path(__file__).parent / "assets" / "ref_fugue_preset.txt"
with open(ref, "r", encoding="utf8") as f_ref:
Expand All @@ -43,7 +42,7 @@ def test_fugue_extension_preset(self) -> None:
)

# TODO: remove decorator once support for Python 3.6 is dropped
@unittest.skipUnless(sys.version_info >= (3, 7), "at least Python 3.7 is required")
@unittest.skipUnless(PYENV >= (3, 7), "at least Python 3.7 is required")
def test_fugue_extension_timeline(self) -> None:
ref = pathlib.Path(__file__).parent / "assets" / "ref_fugue_timeline.txt"
with open(ref, "r", encoding="utf8") as f_ref:
Expand Down

0 comments on commit 9f997d2

Please sign in to comment.