A RetroSearch Logo

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

Search Query:

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

Documentation for "Postponed Annotations" is slightly confusing · Issue #486 · pydantic/pydantic · GitHub

Pydantic version : 0.23

I find this paragraph regarding postponed annotations a bit confusing.

  1. The first example works even without the import, and does not even demonstrate the feature IMO ?!
from __future__ import annotations # Useless !
from typing import List
from pydantic import BaseModel

class Model(BaseModel):
    a: List[int] # Where's the forward reference ?

print(Model(a=('1', 2, 3)))
#> Model a=[1, 2, 3]
  1. It wasn't immediately clear to me that the two suggested solutions (with annotations and ForwardRef) were completely independent indeed (I ended up on support for ForwardRef (forward references) #234 after googling "python typing ForwardRef")

  2. I use Python 3.7.3 and yet have no such thing as ForwardRef in the typing module ? I'm completely unaware of type annotation's internals, but is that solution still relevant ?

Since the first solution works like a charm, I'll be suggesting a PR which emphasizes on it and updates the example


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