A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pydantic/pydantic/issues/248 below:

support for postponed annotations · Issue #248 · pydantic/pydantic · GitHub

Related to #234, postponed annotations (PEP-563) also doesn't appear to be implemented. I think all that is needed here is a call to typing.get_type_hints().

from __future__ import annotations
from pydantic import BaseModel
from typing import Optional

class Foo(BaseModel):
    foo: Optional[Foo]
Traceback (most recent call last):
  File "/home/buhman/env/lib/python3.7/site-packages/pydantic/validators.py", line 262, in find_validators
    if issubclass(type_, val_type):
TypeError: issubclass() arg 1 must be a class

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/buhman/env/lib/python3.7/site-packages/pydantic/main.py", line 121, in __new__
    config=config,
  File "/home/buhman/env/lib/python3.7/site-packages/pydantic/fields.py", line 107, in infer
    schema=schema,
  File "/home/buhman/env/lib/python3.7/site-packages/pydantic/fields.py", line 87, in __init__
    self.prepare()
  File "/home/buhman/env/lib/python3.7/site-packages/pydantic/fields.py", line 136, in prepare
    self._populate_validators()
  File "/home/buhman/env/lib/python3.7/site-packages/pydantic/fields.py", line 266, in _populate_validators
    self.model_config.arbitrary_types_allowed)),
  File "/home/buhman/env/lib/python3.7/site-packages/pydantic/validators.py", line 265, in find_validators
    raise RuntimeError(f'error checking inheritance of {type_!r} (type: {display_as_type(type_)})') from e
RuntimeError: error checking inheritance of 'Optional[Foo]' (type: str)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4