diff --git a/apischema/dataclasses/cache.py b/apischema/dataclasses/cache.py index 4ba654d4..f53d1dda 100644 --- a/apischema/dataclasses/cache.py +++ b/apischema/dataclasses/cache.py @@ -346,7 +346,7 @@ def _serialization( def _deserialization_merged_aliases(cls: Type) -> AbstractSet[str]: """Return all aliases used in cls deserialization.""" - cls = getattr(cls, "__origin__", cls) + cls = getattr(cls, "__origin__", None) or cls types = get_type_hints(cls, include_extras=True) result: Set[str] = set() for field in fields_items(cls).values(): diff --git a/docs/changelog.md b/docs/changelog.md index 979dfcf1..5ae0751c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,9 @@ # Changelog +## 0.7.6 + +- Update package description. + ## 0.7.5 - Fix support of `Generic` merged dataclasses. diff --git a/setup.py b/setup.py index d0bf5acf..8579d56f 100644 --- a/setup.py +++ b/setup.py @@ -5,15 +5,14 @@ setup( name="apischema", - version="0.7.5", + version="0.7.6", url="https://github.com/wyfo/apischema", author="Joseph Perez", author_email="joperez@hotmail.fr", license="MIT", packages=find_packages(include=["apischema*"]), package_data={"apischema": ["py.typed"]}, - description="Another Python API schema handling and JSON (de)serialization " - "through typing annotation; light, simple, powerful.", + description="JSON (de)serialization + schema generation through python typing, with a spoonful of sugar.", # noqa E501 long_description=README, long_description_content_type="text/markdown", python_requires=">=3.6", diff --git a/tests/test_cache.py b/tests/test_cache.py new file mode 100644 index 00000000..6eb20482 --- /dev/null +++ b/tests/test_cache.py @@ -0,0 +1,37 @@ +from dataclasses import InitVar, dataclass, field +from typing import Generic, TypeVar + +from apischema.dataclasses.cache import _deserialization_merged_aliases +from apischema.metadata import merged + + +@dataclass +class A: + a: int + b: "B" = field(metadata=merged) + c: "C[int]" = field(metadata=merged) + d: "D" = field(metadata=merged) + e: InitVar[int] + f: int = field(init=False) + + +@dataclass +class B: + g: int + + +T = TypeVar("T") + + +@dataclass +class C(Generic[T]): + h: T + + +@dataclass +class D(Generic[T]): + i: T + + +def test_merged_aliases(): + assert _deserialization_merged_aliases(A) == {"a", "g", "h", "i", "e"}