File: container_list.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 (33 lines) | stat: -rw-r--r-- 580 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from typing import List, Union

from odmantic import Model


class SimpleListModel(Model):
    field: list


print(SimpleListModel(field=[1, "a", True]).field)
#> [1, 'a', True]
print(SimpleListModel(field=(1, "a", True)).field)
#> [1, 'a', True]


class IntListModel(Model):
    field: List[int]


print(IntListModel(field=[1, 5]).field)
#> [1, 5]
print(IntListModel(field=(1, 5)).field)
#> [1, 5]


class IntStrListModel(Model):
    field: List[Union[int, str]]


print(IntStrListModel(field=[1, "b"]).field)
#> [1, 'b']
print(IntStrListModel(field=(1, "b")).field)
#> [1, 'b']