Skip to content

Commit 9d2a125

Browse files
committed
fix: add exception type in Resource check_all_values validator
1 parent bca7ded commit 9d2a125

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

jsonapi_pydantic/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from jsonapi_pydantic import v1_0
1+
from jsonapi_pydantic import constants, v1_0
22

3-
__version__ = "0.1.1"
3+
__version__ = "0.1.2"
44

5-
__all__ = ["v1_0"]
5+
__all__ = ["constants", "v1_0"]

jsonapi_pydantic/v1_0/resource/resource.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class Resource(BaseModel):
2424
@root_validator
2525
def check_all_values(cls, values: dict) -> dict:
2626
# More about these restrictions: https://jsonapi.org/format/#document-resource-object-fields
27-
attributes, relationships = values.get("attributes"), values.get("relationships")
2827
try:
29-
attributes, relationships = dict(attributes), dict(relationships)
30-
except ValueError:
28+
attributes = dict(values.get("attributes"))
29+
relationships = dict(values.get("relationships"))
30+
except (ValueError, TypeError):
3131
raise ValueError("Attributes and relationships must be json objects.")
3232

3333
if attributes and (attributes.get("id") or attributes.get("type")):

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "jsonapi-pydantic"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "JSON:API implementation with pydantic."
55

66
authors = ["impocode <[email protected]>"]

0 commit comments

Comments
 (0)