odmantic icon indicating copy to clipboard operation
odmantic copied to clipboard

Incompatible With Type Hinting Generics In Standard Collections

Open songzhi opened this issue 4 years ago • 1 comments

from odmantic import Model

class User(Model):
    scopes: list[str]


print(User(scopes=[]))

Caused errors like this:

Traceback (most recent call last):
  File "C:\xxxx\main.py", line 3, in <module>
    class User(Model):
  File "C:\xxxx\lib\site-packages\odmantic\model.py", line 381, in __new__
    mcs.__validate_cls_namespace__(name, namespace)
  File "C:\xxxx\lib\site-packages\odmantic\model.py", line 219, in __validate_cls_namespace__
    substituted_type = validate_type(field_type)
  File "C:\xxxx\lib\site-packages\odmantic\model.py", line 176, in validate_type
    setattr(type_, "__args__", new_arg_types)
AttributeError: readonly attribute

songzhi avatar Dec 08 '20 13:12 songzhi

This is a blocking bug for me--I cannot use odmantic until it's resolved. I guess I've got to use Beanie instead.

MatthewNewland avatar Aug 11 '22 20:08 MatthewNewland