File: union.py

package info (click to toggle)
python-odmantic 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,488 kB
  • sloc: python: 8,646; sh: 110; javascript: 45; makefile: 34; xml: 13
file content (16 lines) | stat: -rw-r--r-- 240 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from typing import Union

from odmantic import Model


class Thing(Model):
    ref_id: Union[int, str]


thing_1 = Thing(ref_id=42)
print(thing_1.ref_id)
#> 42

thing_2 = Thing(ref_id="i am a string")
print(thing_2.ref_id)
#> i am a string