In django-stubs we use descriptors for this task: https://github.com/typeddjango/django-stubs/blob/5092bdf951edb6ef3ba23b28c7e... Simple repro: https://mypy-play.net/?mypy=latest&python=3.11&gist=019398b283c7000ec842a1f4963cc481 ср, 22 мар. 2023 г. в 10:47, Chihiro Sakai <sakaic2003@gmail.com>:
I tried this way, but I found it cannot make `Class.attribute` assignable. With this solution, in the example below, pyright reports an incompatible type error in line 3.
```python class Entity(Base): __tablename__ = 'entity' column_1: AttrAnnotation[Column, int] = Column('column_1', BIGINT(unsigned=True), primary_key=True, autoincrement=True) # ^ Expression of type "Column[int]" cannot be assigned to declared type "AttrAnnotation[Column[Unknown], int]" # "Column[int]" is incompatible with "AttrAnnotation[Column[Unknown], int]" ```
Does anyone still have any idea? _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: n.a.sobolev@gmail.com