From 20df695d8d407e099ba423139b8dfa4d7b18ffe0 Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Thu, 24 Oct 2024 22:08:29 -0500 Subject: [PATCH] Remove deprecated `from_builtins` --- msgspec/__init__.py | 26 -------------------------- msgspec/__init__.pyi | 22 ---------------------- tests/basic_typing_examples.py | 21 --------------------- tests/test_convert.py | 10 ---------- 4 files changed, 79 deletions(-) diff --git a/msgspec/__init__.py b/msgspec/__init__.py index 2bd99f58..421e4311 100644 --- a/msgspec/__init__.py +++ b/msgspec/__init__.py @@ -20,32 +20,6 @@ def field(*, default=NODEFAULT, default_factory=NODEFAULT, name=None): return _Field(default=default, default_factory=default_factory, name=name) -def from_builtins( - obj, - type, - *, - str_keys=False, - str_values=False, - builtin_types=None, - dec_hook=None, -): - """DEPRECATED: use ``msgspec.convert`` instead""" - import warnings - - warnings.warn( - "`msgspec.from_builtins` is deprecated, please use `msgspec.convert` instead", - stacklevel=2, - ) - return convert( - obj, - type, - strict=not str_values, - dec_hook=dec_hook, - builtin_types=builtin_types, - str_keys=str_keys, - ) - - field.__doc__ = _Field.__doc__ diff --git a/msgspec/__init__.pyi b/msgspec/__init__.pyi index c44f2b32..4d2d8744 100644 --- a/msgspec/__init__.pyi +++ b/msgspec/__init__.pyi @@ -177,28 +177,6 @@ def convert( str_keys: bool = False, ) -> Any: ... -# TODO: deprecated -@overload -def from_builtins( - obj: Any, - type: Type[T], - *, - str_keys: bool = False, - str_values: bool = False, - builtin_types: Union[Iterable[type], None] = None, - dec_hook: Optional[Callable[[type, Any], Any]] = None, -) -> T: ... -@overload -def from_builtins( - obj: Any, - type: Any, - *, - str_keys: bool = False, - str_values: bool = False, - builtin_types: Union[Iterable[type], None] = None, - dec_hook: Optional[Callable[[type, Any], Any]] = None, -) -> Any: ... - class MsgspecError(Exception): ... class EncodeError(MsgspecError): ... class DecodeError(MsgspecError): ... diff --git a/tests/basic_typing_examples.py b/tests/basic_typing_examples.py index 33dcb009..9ff5b5c7 100644 --- a/tests/basic_typing_examples.py +++ b/tests/basic_typing_examples.py @@ -1134,24 +1134,3 @@ def check_convert() -> None: o7 = msgspec.convert("1", int, str_keys=True) reveal_type(o7) # assert "int" in typ.lower() - - -def check_from_builtins() -> None: - """TODO: deprecated""" - o1 = msgspec.from_builtins(1, int) - reveal_type(o1) # assert "int" in typ.lower() - - o2 = msgspec.from_builtins([1, 2], List[float]) - reveal_type(o2) # assert "list" in typ.lower() - - o3 = msgspec.from_builtins(1, int, str_keys=False) - reveal_type(o3) # assert "int" in typ.lower() - - o4 = msgspec.from_builtins("1", int, str_values=True) - reveal_type(o4) # assert "int" in typ.lower() - - o5 = msgspec.from_builtins(1, int, builtin_types=(bytes, bytearray, memoryview)) - reveal_type(o5) # assert "int" in typ.lower() - - o6 = msgspec.from_builtins(1, int, dec_hook=lambda typ, x: None) - reveal_type(o6) # assert "int" in typ.lower() diff --git a/tests/test_convert.py b/tests/test_convert.py index c7eb79af..afb456cc 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -182,16 +182,6 @@ def roundtrip(obj, typ): return convert(to_builtins(obj), typ) -class TestFromBuiltins: - """TODO: deprecated""" - - def test_from_builtins(self): - with pytest.warns(UserWarning, match="deprecated"): - res = msgspec.from_builtins([1, 2], List[float]) - assert res == [1.0, 2.0] - assert type(res[0]) is float - - class TestConvert: def test_bad_calls(self): with pytest.raises(TypeError):