-
Notifications
You must be signed in to change notification settings - Fork 238
implicit casting for predefined type #1056
Copy link
Copy link
Closed
Labels
DocArray v2This issue is part of the rewrite; not to be merged into mainThis issue is part of the rewrite; not to be merged into main
Description
Context
Instantiating a predefined document is quite verbose atm
from docarray import BaseDocument
from docarray.documents import Text, Image
class MyDoc(BaseDocument):
text: Text
image: Image
my_doc = MyDoc(text=Text(text='hello'), image=Image(url='http://fjdjnsfsger.jpg')))We want to make it less verbose
proposition
cast
we could allow doing the following
my_doc = MyDoc(text='hello', image='http://fdsgd.jpg')and automatically "cast" or validate
This has been merged in #1058
Init less verbose (#1067)
txt = Text(text='hello')is too verbose, we should allow doing
txt = Text('hello')We should rely on the same mechanism as for the validation of this pr #1058
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DocArray v2This issue is part of the rewrite; not to be merged into mainThis issue is part of the rewrite; not to be merged into main
Type
Projects
Status
Done