Skip to content

remove deprecated code #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/source/about/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand Down Expand Up @@ -65,10 +73,14 @@ v0.42.0
- :pull:`832` - Fix ``html_to_vdom`` improperly removing ``<html>``, ``<head>``, and ``<body>`` 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
-------
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
23 changes: 7 additions & 16 deletions src/idom/_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 0 additions & 7 deletions src/idom/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pathlib import Path
from tempfile import TemporaryDirectory

from ._option import DeprecatedOption as _DeprecatedOption
from ._option import Option as _Option


Expand Down Expand Up @@ -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,
Expand Down
38 changes: 0 additions & 38 deletions src/idom/core/_event_proxy.py

This file was deleted.

3 changes: 1 addition & 2 deletions src/idom/core/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 11 additions & 1 deletion tests/test__option.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from idom._option import Option
from idom._option import DeprecatedOption, Option


def test_option_repr():
Expand Down Expand Up @@ -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"