File: typing_err1.py

package info (click to toggle)
sqlalchemy 2.0.40%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,404 kB
  • sloc: python: 410,002; makefile: 230; sh: 7
file content (31 lines) | stat: -rw-r--r-- 636 bytes parent folder | download | duplicates (4)
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
from sqlalchemy import Column
from sqlalchemy import Integer
from sqlalchemy.orm import registry
from sqlalchemy.types import TypeEngine


# EXPECTED_MYPY: Missing type parameters for generic type "TypeEngine"
class MyCustomType(TypeEngine):
    pass


# correct way
class MyOtherCustomType(TypeEngine[str]):
    pass


reg: registry = registry()


@reg.mapped
class Foo:
    id: int = Column(Integer())

    name = Column(MyCustomType())
    other_name: str = Column(MyCustomType())

    name2 = Column(MyOtherCustomType())
    other_name2: str = Column(MyOtherCustomType())


Foo(name="x", other_name="x", name2="x", other_name2="x")