Skip to content

Commit

Permalink
remove deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjinliu committed Sep 20, 2024
1 parent 50704eb commit 40221cb
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 152 deletions.
19 changes: 0 additions & 19 deletions tabulous/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,28 +184,9 @@ class EvalInfo(NamedTuple):
expr: str
is_ref: bool

@property
def col(self) -> int:
"""Alias of `column`."""
return self.column


_Sliceable = Union[SupportsIndex, slice]
_SingleSelection = Tuple[_Sliceable, _Sliceable]
SelectionType = List[_SingleSelection]


def __getattr__(name: str) -> Any:
if name == "FilterType":
import warnings

warnings.warn(
"'FilterType 'is deprecated. Please use 'ProxyType' instead.",
DeprecationWarning,
)
return ProxyType
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


ColorType = Union[str, Iterable[int]]
ColorMapping = Union[Callable[[Any], ColorType], Mapping[str, ColorType]]
18 changes: 0 additions & 18 deletions tabulous/widgets/_component/_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Any,
Iterator,
)
import warnings

from qtpy import QtGui
from qtpy.QtCore import Qt
Expand Down Expand Up @@ -232,23 +231,6 @@ def selected_at(self, r: int, c: int) -> bool:
return True
return False

def get_label(self, r: int, c: int) -> str | None:
"""Get the label of a cell."""
warnings.warn(
"get_label is deprecated. Use `table.cell.label[r, c]` instead.",
DeprecationWarning,
)
return self.label[r, c]

def set_label(self, r: int, c: int, text: str):
"""Set the label of a cell."""
warnings.warn(
f"set_label is deprecated. Use `table.cell.label[r, c] = {text!r}` "
"instead.",
DeprecationWarning,
)
self.label[r, c] = text

def set_labeled_data(
self,
r: int,
Expand Down
9 changes: 0 additions & 9 deletions tabulous/widgets/_component/_column_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
Sequence,
)
from functools import wraps
import warnings

import numpy as np

Expand Down Expand Up @@ -399,11 +398,3 @@ def set(
if formatting:
self.parent._qwidget._set_default_text_formatter(name)
return None

def set_dtype(self, *args, **kwargs) -> None:
"""Deprecated alias for set()."""
warnings.warn(
"set_dtype() is deprecated, use set() instead.",
DeprecationWarning,
)
return self.set(*args, **kwargs)
14 changes: 0 additions & 14 deletions tabulous/widgets/_component/_keymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,3 @@ def unregister(self, key: str) -> None:
def press_key(self, key: str) -> None:
self.parent._qwidget._keymap.press_key(key)
return None


def bind(self: KeyMap, *args, **kwargs):
import warnings

warnings.warn(
"Keycombo registration using `keymap.bind` is deprecated. Use "
"`keymap.register` instead.",
DeprecationWarning,
)
return self.parent._qwidget._keymap.bind(*args, **kwargs)


KeyMap.bind = bind # backward compatibility
29 changes: 7 additions & 22 deletions tabulous/widgets/_mainwindow.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from __future__ import annotations

from abc import ABC, abstractproperty
from abc import ABC, abstractmethod
from functools import partial
from pathlib import Path
from types import MappingProxyType
import warnings
import weakref
from enum import Enum
from typing import TYPE_CHECKING, Any, Callable, Generic, Union, TypeVar
Expand Down Expand Up @@ -50,15 +49,18 @@ class TableViewerSignal(SignalGroup):


class _AbstractViewer(ABC):
@abstractproperty
@property
@abstractmethod
def current_table(self) -> TableBase | None:
"""Return the currently visible table."""

@abstractproperty
@property
@abstractmethod
def current_index(self) -> int | None:
"""Return the index of currently visible table."""

@abstractproperty
@property
@abstractmethod
def cell_namespace(self) -> Namespace:
"""Return the namespace of the cell editor."""

Expand Down Expand Up @@ -399,15 +401,6 @@ def open(self, path: PathLike, *, type: TableType | str = TableType.table) -> No
_utils.dump_file_open_path(path)
return None

def save(self, path: PathLike) -> None:
"""Save current table."""
warnings.warn(
"viewer.save() is deprecated. Use table.save() instead.",
DeprecationWarning,
)
_io.save_file(path, self.current_table.data)
return None

def save_all(self, path: PathLike) -> None:
"""Save all tables."""
path = Path(path)
Expand Down Expand Up @@ -503,14 +496,6 @@ def status(self, tip: str) -> None:
statusbar = self._qwidget.statusBar()
return statusbar.showMessage(tip)

def resize(self, width: int, height: int):
"""Resize the table viewer."""
warnings.warn(
"viewer.resize() is deprecated. Use `viewer.size` instead.",
DeprecationWarning,
)
self.size = width, height

@property
def size(self) -> tuple[int, int]:
"""Return the size of the table viewer."""
Expand Down
38 changes: 0 additions & 38 deletions tabulous/widgets/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,44 +70,6 @@ def unregister(self, location: str):
self._get_qregistry().unregisterAction(location)


def register_action(self: SupportActionRegistration, *args):
"""Register an contextmenu action."""
import warnings

warnings.warn(
"`register_action` is deprecated. Use `register` instead.",
DeprecationWarning,
)

reg = self._get_qregistry()
nargs = len(args)
if nargs == 0 or nargs > 2:
raise TypeError("One or two arguments are allowed.")
if nargs == 1:
arg = args[0]
if callable(arg):
loc, func = getattr(arg, "__name__", repr(arg)), arg
else:
loc, func = arg, None
else:
loc, func = args

# check type
if not isinstance(loc, str) or (func is not None and not callable(func)):
arg = type(loc).__name__
if func is not None:
arg += f", {type(func).__name__}"
raise TypeError(f"No overloaded method matched the input ({arg}).")

def wrapper(f: Callable[[int], Any]):
reg.registerAction(loc, f)
return f

return wrapper if func is None else wrapper(func)


SupportActionRegistration.register_action = register_action

# e.g. f() takes from 0 to 1 positional arguments but 2 were given
_PATTERN = re.compile(r".*takes .* positional arguments? but (\d+) w.+ given")

Expand Down
36 changes: 4 additions & 32 deletions tabulous/widgets/_table.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from __future__ import annotations

import logging
from abc import abstractmethod, abstractstaticmethod
from abc import abstractmethod
import ast
from enum import Enum
from pathlib import Path
from typing import Any, Callable, Hashable, TYPE_CHECKING, Mapping, overload
import warnings
import weakref
from psygnal import SignalGroup, Signal

Expand Down Expand Up @@ -42,26 +41,6 @@ class TableSignals(SignalGroup):
renamed = Signal(str)
_table: weakref.ReferenceType[TableBase]

@property
def index(self):
warnings.warn(
"`table.events.index` is deprecated. Please use `table.index.events."
"renamed` instead.",
DeprecationWarning,
)
table = self._table()
return table.index.events.renamed

@property
def columns(self):
warnings.warn(
"`table.events.columns` is deprecated. Please use `table.columns.events."
"renamed` instead.",
DeprecationWarning,
)
table = self._table()
return table.columns.events.renamed


class ViewMode(Enum):
"""Enum of view modes"""
Expand Down Expand Up @@ -200,14 +179,6 @@ def __getitem__(self, key):
return _comp.TableSubset(self, slice(None), key)
raise TypeError(f"Invalid key type: {type(key)}")

@property
def cellref(self):
warnings.warn(
"table.cellref is deprecated. Use table.cell.ref instead.",
DeprecationWarning,
)
return self.cell.ref

@property
def source(self) -> Source:
"""The source of the table."""
Expand Down Expand Up @@ -257,8 +228,9 @@ def _emit_data_changed_signal(self, info: ItemInfo) -> None:
def _create_backend(self, data: pd.DataFrame) -> QBaseTable:
"""This function creates a backend widget."""

@abstractstaticmethod
def _normalize_data(self, data):
@staticmethod
@abstractmethod
def _normalize_data(data):
"""Data normalization before setting a new data."""

@property
Expand Down

0 comments on commit 40221cb

Please sign in to comment.