diff --git a/docs/source/about/changelog.rst b/docs/source/about/changelog.rst index f793a8fda..76f82965f 100644 --- a/docs/source/about/changelog.rst +++ b/docs/source/about/changelog.rst @@ -28,6 +28,14 @@ Unreleased - :pull:`876` - ``idom.widgets.hotswap``. The function has no clear uses outside of some internal applications. For this reason it has been deprecated. +**Removed** + +- :pull:`886` - Ability to access element value from events via `event['value']` key. + Instead element value should be accessed via `event['target']['value']`. Originally + deprecated in :ref:`v0.34.0`. +- :pull:`886` - old misspelled option ``idom.config.IDOM_WED_MODULES_DIR``. Originally + deprecated in :ref:`v0.36.1`. + v0.43.0 ------- @@ -65,10 +73,14 @@ v0.42.0 - :pull:`832` - Fix ``html_to_vdom`` improperly removing ````, ````, and ```` nodes. **Removed** + - :pull:`832` - Removed ``idom.html.body`` as it is currently unusable due to technological limitations, and thus not needed. - :pull:`840` - remove ``IDOM_FEATURE_INDEX_AS_DEFAULT_KEY`` option - :pull:`835` - ``serve_static_files`` option from backend configuration +**Deprecated** + +- :commit:`8f3785b` - Deprecated ``module_from_template`` v0.41.0 ------- diff --git a/noxfile.py b/noxfile.py index 65aa4a52c..9e64c02fe 100644 --- a/noxfile.py +++ b/noxfile.py @@ -204,6 +204,7 @@ def test_python_types(session: Session) -> None: install_requirements_file(session, "check-types") install_requirements_file(session, "pkg-deps") install_requirements_file(session, "pkg-extras") + session.run("mypy", "--version") session.run("mypy", "--show-error-codes", "--strict", "src/idom") diff --git a/src/idom/_option.py b/src/idom/_option.py index 7fb1b7ecd..d9d8e9d79 100644 --- a/src/idom/_option.py +++ b/src/idom/_option.py @@ -120,27 +120,18 @@ def __repr__(self) -> str: class DeprecatedOption(Option[_O]): # pragma: no cover - def __init__(self, new_opt: Option[_O], name: str) -> None: - # copy over attrs - attrs = new_opt.__dict__.copy() - attrs.pop("_current", None) - self.__dict__.update(new_opt.__dict__) - # then set the ones needed here - self._name = name - self._new_opt = new_opt + def __init__(self, message: str, *args: Any, **kwargs: Any) -> None: + self._deprecation_message = message + super().__init__(*args, **kwargs) - @property # type: ignore - def _current(self) -> _O: + @Option.current.getter # type: ignore + def current(self) -> _O: warn( - f"{self.name!r} has been renamed to {self._new_opt.name!r}", + self._deprecation_message, DeprecationWarning, stacklevel=_frame_depth_in_module() + 1, ) - return self._new_opt.current - - @_current.setter - def _current(self, new: _O) -> None: - self._new_opt.current = new + return super().current def _frame_depth_in_module() -> int: diff --git a/src/idom/config.py b/src/idom/config.py index ab65feea6..fa7617638 100644 --- a/src/idom/config.py +++ b/src/idom/config.py @@ -6,7 +6,6 @@ from pathlib import Path from tempfile import TemporaryDirectory -from ._option import DeprecatedOption as _DeprecatedOption from ._option import Option as _Option @@ -54,12 +53,6 @@ set of publically available APIs for working with the client. """ -IDOM_WED_MODULES_DIR: _Option[Path] = _DeprecatedOption( - new_opt=IDOM_WEB_MODULES_DIR, - name="IDOM_WED_MODULES_DIR", -) -"""This has been renamed to :data:`IDOM_WEB_MODULES_DIR`""" - IDOM_TESTING_DEFAULT_TIMEOUT = _Option( "IDOM_TESTING_DEFAULT_TIMEOUT", 5.0, diff --git a/src/idom/core/_event_proxy.py b/src/idom/core/_event_proxy.py deleted file mode 100644 index 5c47aa57f..000000000 --- a/src/idom/core/_event_proxy.py +++ /dev/null @@ -1,38 +0,0 @@ -from typing import Any, Dict, Sequence -from warnings import warn - - -def _wrap_in_warning_event_proxies(values: Sequence[Any]) -> Sequence[Any]: - return [_EventProxy(x) if isinstance(x, dict) else x for x in values] - - -class _EventProxy(Dict[Any, Any]): - def __getitem__(self, key: Any) -> Any: # pragma: no cover - try: - return super().__getitem__(key) - except KeyError: - target = self.get("target") - if isinstance(target, dict) and key in target: - warn( - f"The event key event[{key!r}] has been moved event['target'][{key!r}", - DeprecationWarning, - stacklevel=2, - ) - return target[key] - else: - raise - - def get(self, key: Any, default: Any = None) -> Any: # pragma: no cover - try: - return super().__getitem__(key) - except KeyError: - target = self.get("target") - if isinstance(target, dict) and key in target: - warn( - f"The event key event[{key!r}] has been moved event['target'][{key!r}", - DeprecationWarning, - stacklevel=2, - ) - return target[key] - else: - return default diff --git a/src/idom/core/layout.py b/src/idom/core/layout.py index ee7f67da6..a0bbad042 100644 --- a/src/idom/core/layout.py +++ b/src/idom/core/layout.py @@ -26,7 +26,6 @@ from idom.config import IDOM_CHECK_VDOM_SPEC, IDOM_DEBUG_MODE from idom.utils import Ref -from ._event_proxy import _wrap_in_warning_event_proxies from .hooks import LifeCycleHook from .types import ( ComponentType, @@ -99,7 +98,7 @@ async def deliver(self, event: LayoutEventMessage) -> None: if handler is not None: try: - await handler.function(_wrap_in_warning_event_proxies(event["data"])) + await handler.function(event["data"]) except Exception: logger.exception(f"Failed to execute event handler {handler}") else: diff --git a/tests/test__option.py b/tests/test__option.py index 144860117..52fe6d258 100644 --- a/tests/test__option.py +++ b/tests/test__option.py @@ -3,7 +3,7 @@ import pytest -from idom._option import Option +from idom._option import DeprecatedOption, Option def test_option_repr(): @@ -99,3 +99,13 @@ def test_option_subscribe(): opt.unset() assert calls == ["default", "new-1", "new-2", "default"] + + +def test_deprecated_option(): + opt = DeprecatedOption("is deprecated!", "A_FAKE_OPTION", None) + + with pytest.warns(DeprecationWarning, match="is deprecated!"): + opt.current + + with pytest.warns(DeprecationWarning, match="is deprecated!"): + opt.current = "something"