Skip to content

Commit 6401120

Browse files
committed
add help message to vdom constructor
1 parent 598bcf7 commit 6401120

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/idom/core/vdom.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from __future__ import annotations
22

33
import logging
4-
from typing import Any, Mapping, cast
4+
from functools import wraps
5+
from typing import Any, Mapping, TypeVar, cast
6+
from warnings import warn
57

68
from fastjsonschema import compile as compile_json_schema
79

@@ -128,6 +130,31 @@ def is_vdom(value: Any) -> bool:
128130
)
129131

130132

133+
_T = TypeVar("_T")
134+
135+
136+
def _help_message(func: _T) -> _T:
137+
@wraps(func)
138+
def wrapper(*args, **kwargs):
139+
try:
140+
return func(*args, **kwargs)
141+
except TypeError: # pragma: no cover
142+
warn(
143+
(
144+
"Element constructor signatures have changed! A CLI tool for "
145+
"automatically updating code to the latest API has been provided "
146+
"with this release of IDOM (e.g. 'idom update-html-usages'). For "
147+
"start a discussion if you need help transitioning to this new "
148+
"interface: https://github.com/idom-team/idom/discussions/new?category=question"
149+
),
150+
UserWarning,
151+
)
152+
raise
153+
154+
return wrapper
155+
156+
157+
@_help_message
131158
def vdom(
132159
tag: str, *children: VdomChild, key: Key | None = None, **attributes: Any
133160
) -> VdomDict:

0 commit comments

Comments
 (0)