lexiq-legal / pydantic_schemaorg

Schema.org classes in pydantic
MIT License
61 stars 18 forks source link

Example does not work with pydantic >1.9 #6

Open apirogov opened 2 years ago

apirogov commented 2 years ago

I could not run the example in the README:

from pydantic_schemaorg.ScholarlyArticle import ScholarlyArticle
scholarly_article = ScholarlyArticle(url='https://github.com/lexiq-legal/pydantic_schemaorg',
                                        sameAs='https://github.com/lexiq-legal/pydantic_schemaorg',
                                        copyrightNotice='Free to use under the MIT license',
                                        dateCreated='15-12-2021')

raises for me

  File "pydantic/typing.py", line 551, in pydantic.typing.update_model_forward_refs

  File "pydantic/typing.py", line 526, in pydantic.typing.update_field_forward_refs
    return NotImplemented
  File "pydantic/typing.py", line 526, in pydantic.typing.update_field_forward_refs
    return NotImplemented
  File "pydantic/typing.py", line 526, in pydantic.typing.update_field_forward_refs
    return NotImplemented
  File "pydantic/typing.py", line 521, in pydantic.typing.update_field_forward_refs
    self.__forward_evaluated__ = True
  File "pydantic/typing.py", line 69, in pydantic.typing.evaluate_forwardref
    'Coroutine',
  File ".../python3.8/typing.py", line 518, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
NameError: name 'URL' is not defined
crbaker89 commented 2 years ago

@apirogov I see that it an issue on python < 3.9. Switching to python 3.9 can resolve your issue.

In the mean time i will put this issue on the backlog

ohad-alike commented 2 years ago

I'm having this as well. downgrading to pydantic==1.9.0 did not solve this. we are using python 3.8