You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to the issue, #58, but in this case List[Optional[Repository]] fails with an exception. Here is some sample code. The error occurred with dataclasses-json version 0.2.2
Error
/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/mm.py:70:
UserWarning: Unknown type <class 'NoneType'> at Breaks.nodes: typing.List[typing.Union[__main__.Repository, NoneType]]
It's advised to pass the correct marshmallow type to `mm_field`.
warnings.warn(f"Unknown type {type_} at {cls.__name__}.{field.name}: {field.type} "
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/api.py", line 76, in schema
Schema = build_schema(cls, DataClassJsonMixin, infer_missing, partial)
File "/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/mm.py", line 113, in build_schema
schema_ = schema(cls, mixin, infer_missing)
File "/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/mm.py", line 98, in schema
t = build_type(type_, options, mixin, field, cls)
File "/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/mm.py", line 73, in build_type
return inner(type_, options)
File "/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/mm.py", line 66, in inner
args = [inner(a, {}) for a in getattr(type_, '__args__', [])]
File "/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/mm.py", line 66, in <listcomp>
args = [inner(a, {}) for a in getattr(type_, '__args__', [])]
File "/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/mm.py", line 66, in inner
args = [inner(a, {}) for a in getattr(type_, '__args__', [])]
File "/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/mm.py", line 66, in <listcomp>
args = [inner(a, {}) for a in getattr(type_, '__args__', [])]
File "/Users/PC/miniconda3/envs/Flask_async/lib/python3.7/site-packages/dataclasses_json/mm.py", line 72, in inner
return field.Field(**options)
Code example:
from dataclasses import dataclass
from dataclasses_json import dataclass_json
from typing import List, Optional
@dataclass_json
@dataclass
class Repository:
name: str
stargazers: str
@dataclass_json
@dataclass
class Breaks:
errors_with_trace = ''"
nodes: List[Optional[Repository]]
@dataclass_json
@dataclass
class Works:
nodes: Optional[List[Repository]]
try:
Breaks.schema()
except AttributeError as exc:
print(exc)
Works.schema()
The text was updated successfully, but these errors were encountered:
Similar to the issue, #58, but in this case
List[Optional[Repository]]
fails with an exception. Here is some sample code. The error occurred with dataclasses-json version 0.2.2Error
Code example:
The text was updated successfully, but these errors were encountered: