File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 22Tests to ensure that the SQLModel `Field` constructor works as
33expected from the Pydantic `Field` function.
44"""
5+ import sys
56from decimal import Decimal
6- from typing import List , Literal , Optional , Union
7+ from typing import List , Optional , Union
78
89import pytest
910from pydantic import ValidationError
@@ -35,9 +36,15 @@ class Model(SQLModel):
3536 Model (unique_strings = ["x" , "y" , "x" ])
3637
3738
39+ @pytest .mark .skipif (
40+ sys .version_info < (3 , 8 ), reason = "requires Python 3.8+ (for `typing.Literal`)"
41+ )
3842def test_discriminator ():
43+ from typing import Literal
44+
3945 # Example adapted from
4046 # [Pydantic docs](https://pydantic-docs.helpmanual.io/usage/types/#discriminated-unions-aka-tagged-unions):
47+
4148 class Cat (SQLModel ):
4249 pet_type : Literal ["cat" ]
4350 meows : int
You can’t perform that action at this time.
0 commit comments