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

Exception thrown if rating contains a blank 'pt_prior' field #129

Closed
GrandSlam90 opened this issue Aug 17, 2021 · 1 comment
Closed

Exception thrown if rating contains a blank 'pt_prior' field #129

GrandSlam90 opened this issue Aug 17, 2021 · 1 comment

Comments

@GrandSlam90
Copy link

When attempting to get the ratings for 'AAPL' today, I came across the above error. Specifically, I get:

pydantic.error_wrappers.ValidationError: 1 validation error for Rating
pt_prior
  value is not a valid float (type=type_error.float)

Debugging the data, it appears sometimes the JSON returns the key but with an empty value which I think is what is throwing the exception.
Adding the code below seems to fix things:

    pt_prior: Optional[float] = None
+    @pydantic.validator('pt_prior', pre=True)
+    def pt_prior_blank_string(value, field):
+        if value == "":
+            return None
+        return value
    url_calendar: Optional[str] = None

Hope this helps.

Thanks for all your hard work.

stabacco added a commit that referenced this issue Aug 20, 2021
stabacco added a commit that referenced this issue Aug 20, 2021
@stabacco
Copy link
Owner

Thanks @GrandSlam90 for reporting and suggesting a fix. It should now be available in the 0.3.2 release.
Closing this.

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

No branches or pull requests

2 participants