diff --git a/examples/03-0_data_changed_signal.py b/examples/03-0_data_changed_signal.py index 8c3e654a..b426b105 100644 --- a/examples/03-0_data_changed_signal.py +++ b/examples/03-0_data_changed_signal.py @@ -1,10 +1,7 @@ -import sys from tabulous import TableViewer from tabulous.types import ItemInfo import numpy as np -PY_38 = sys.version_info <= (3, 8) - if __name__ == "__main__": viewer = TableViewer() size = 100 @@ -24,15 +21,13 @@ def _on_data_change(info: ItemInfo): f"{info.old_value} to {info.value}." ) - if PY_38: - # NOTE: Python <= 3.8 does not support __getitem__ in a decorator - def _on_data_change(info: ItemInfo): - print("data at row 0 changed.") - table.events.data[0, :].connect(_on_data_change) + def _on_data_change(info: ItemInfo): + print("data at row 0 changed.") + table.events.data[0, :].connect(_on_data_change) - else: - @table.events.data[0, :].connect - def _on_data_change(info: ItemInfo): - print("data at row 0 changed.") + # NOTE: Python >= 3.9 supports this syntax + # >>> @table.events.data[0, :].connect + # >>> def _on_data_change(info: ItemInfo): + # ... print("data at row 0 changed.") viewer.show() diff --git a/tabulous/_colormap.py b/tabulous/_colormap.py index e82de8fc..e3a7d645 100644 --- a/tabulous/_colormap.py +++ b/tabulous/_colormap.py @@ -10,9 +10,8 @@ import pandas as pd _TimeLike = Union[pd.Timestamp, pd.Timedelta] + _ColorType = tuple[int, int, int, int] - -_ColorType = tuple[int, int, int, int] _DEFAULT_MIN = "#697FD1" _DEFAULT_MAX = "#FF696B" diff --git a/tabulous/commands/_dialogs.py b/tabulous/commands/_dialogs.py index 9c2ef338..faf54c9a 100644 --- a/tabulous/commands/_dialogs.py +++ b/tabulous/commands/_dialogs.py @@ -1,5 +1,5 @@ from functools import partial -from typing import List, Union, TYPE_CHECKING +from typing import List, Union, TYPE_CHECKING, Tuple from typing_extensions import Annotated import logging @@ -206,7 +206,7 @@ def hist( label: SelectionOperator, table: TableBase, bins: int = 10, - range: tuple[str, str] = ("", ""), + range: Tuple[str, str] = ("", ""), alpha: float = 1.0, density: bool = False, histtype: str = "bar", diff --git a/tabulous/widgets/_table.py b/tabulous/widgets/_table.py index fdfdfd6d..dd036777 100644 --- a/tabulous/widgets/_table.py +++ b/tabulous/widgets/_table.py @@ -596,7 +596,10 @@ def _normalize_data(data) -> pd.DataFrame: import pandas as pd if not isinstance(data, pd.DataFrame): - mod = type(data).__module__.split(".", 1)[0] + try: + mod = type(data).__module__.split(".", 1)[0] + except AttributeError: + mod = "" if mod == "polars": import polars as pl diff --git a/tests/test_core.py b/tests/test_core.py index 64409de9..73b712c0 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -17,7 +17,7 @@ def test_io(): tbl.read_csv(DATA_PATH / "test.csv").close() @pytest.mark.parametrize( - "fname", [f for f in glob("examples/*.py") if "napari" not in f] + "fname", [f for f in glob("examples/*.py") if "napari" not in f and "seaborn" not in f] ) def test_examples(fname): with warnings.catch_warnings():