mirror of
https://github.com/rio-labs/rio.git
synced 2026-01-07 05:39:47 -06:00
fix stacklevel of deprecation warnings
This commit is contained in:
@@ -335,9 +335,6 @@ class Component(abc.ABC, metaclass=ComponentMeta):
|
||||
width: float | Literal["grow", "natural"] | None = kwargs.pop(
|
||||
"width", None
|
||||
)
|
||||
height: float | Literal["grow", "natural"] | None = kwargs.pop(
|
||||
"height", None
|
||||
)
|
||||
|
||||
if width is None:
|
||||
pass
|
||||
@@ -345,6 +342,7 @@ class Component(abc.ABC, metaclass=ComponentMeta):
|
||||
deprecations.warn(
|
||||
since="0.9.3",
|
||||
message="The `width` attribute of `rio.Component` is deprecated. Please use `min_width` and `grow_x` instead.",
|
||||
stacklevel=6,
|
||||
)
|
||||
|
||||
if width == "natural":
|
||||
@@ -354,12 +352,17 @@ class Component(abc.ABC, metaclass=ComponentMeta):
|
||||
else:
|
||||
kwargs["min_width"] = width
|
||||
|
||||
height: float | Literal["grow", "natural"] | None = kwargs.pop(
|
||||
"height", None
|
||||
)
|
||||
|
||||
if height is None:
|
||||
pass
|
||||
else:
|
||||
deprecations.warn(
|
||||
since="0.9.3",
|
||||
message="The `height` attribute of `rio.Component` is deprecated. Please use `min_height` and `grow_y` instead.",
|
||||
stacklevel=6,
|
||||
)
|
||||
|
||||
if height == "natural":
|
||||
|
||||
@@ -27,10 +27,12 @@ def warn(
|
||||
*,
|
||||
since: str,
|
||||
message: str,
|
||||
stacklevel: int = 1,
|
||||
) -> None:
|
||||
warnings.warn(
|
||||
f"Deprecated since version {since}: {message}",
|
||||
RioDeprecationWarning,
|
||||
stacklevel=stacklevel,
|
||||
)
|
||||
|
||||
|
||||
@@ -96,6 +98,7 @@ def component_kwarg_renamed(
|
||||
warn(
|
||||
since=since,
|
||||
message=f"The `{old_name}` parameter of `rio.{component_class.__name__}` is deprecated. Please use `{new_name}` instead.",
|
||||
stacklevel=6,
|
||||
)
|
||||
|
||||
# Delegate to the original _remap_constructor_arguments method
|
||||
|
||||
Reference in New Issue
Block a user