Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: RegionRestriction model fields are not optional #177

Closed
pidi3000 opened this issue May 22, 2024 · 1 comment · Fixed by #180
Closed

Bug: RegionRestriction model fields are not optional #177

pidi3000 opened this issue May 22, 2024 · 1 comment · Fixed by #180

Comments

@pidi3000
Copy link
Contributor

Problem

Currently if the RegionRestriction object exists for a video, it is expected to have both fields (allowed, blocked).

allowed: List[str] = field(default=None)
blocked: List[str] = field(default=None, repr=False)

But some video only have 1 set while the other is None,
resulting in this error:

{project_root}/.venv/lib/site-packages/dataclasses_json/core.py:184: RuntimeWarning: `NoneType` object value of non-optional type allowed detected when decoding RegionRestriction.

Solution

From my understanding both fields should be marked as optional,
like this:

allowed: Optional[List[str]] = field(default=None)
blocked: Optional[List[str]] = field(default=None, repr=False)

The ideal way would probably be to somehow define that at least 1 of the 2 is needed and the other is optional.
But I don't think that is possible.

@MerleLiuKun
Copy link
Member

Yes, This need to add Optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants