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

jsonld.expand() fails if the document contains a value which does not plainly serialize to JSON #146

Open
anatoly-scherbakov opened this issue Jan 11, 2021 · 0 comments

Comments

@anatoly-scherbakov
Copy link
Contributor

from pyld import jsonld
from datetime import date

jsonld.expand({'@context': {'@vocab': 'https://schema.org/'}, '@id': 'https://example.blog/post', 'publicationDate': datetime.date(2021, 1, 11)})

Which gives:

...
  File "{venv}/lib/python3.8/site-packages/pyld/jsonld.py", line 3523, in _expand_value
    if not (_is_bool(value) or _is_numeric(value) or _is_string(value)):
  File "{venv}/lib/python3.8/site-packages/pyld/jsonld.py", line 6402, in _is_numeric
    float(v)
TypeError: float() argument must be a string or a number, not 'datetime.date'
  1. Is this intended behavior? If yes, I probably could come up with a PR which would print a human understandable message instead of crash;
  2. If it is not, maybe date and datetime values should be natively supported by the library.
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

1 participant