This repository was archived by the owner on Sep 16, 2024. It is now read-only.
Description Hey, I have a behaviour which I think is a bug / missing functionality.
Here is the code (using typedload==2.7):
from typing import Optional , TypedDict
import typedload
class ExampleTypedDict (TypedDict ):
a : int
b : Optional [int ]
d = {"a" : 0 }
print (f"{ d = } " )
td = ExampleTypedDict (** d )
print (f"{ td = } " )
tdl = typedload .load (d , ExampleTypedDict )
And here is the result of running it:
➜ optional_typeddict pipenv run python main .py
d = {'a' : 0 }
td = {'a' : 0 }
Traceback (most recent call last ):
File "/Users/kkom/Desktop/optional_typeddict/main.py" , line 17 , in < module >
tdl = typedload .load (d , ExampleTypedDict )
File "/Users/kkom/.local/share/virtualenvs/optional_typeddict-hmzsbyx_/lib/python3.9/site-packages/typedload/__init__.py" , line 200 , in load
return loader .load (value , type_ )
File "/Users/kkom/.local/share/virtualenvs/optional_typeddict-hmzsbyx_/lib/python3.9/site-packages/typedload/dataloader.py" , line 294 , in load
raise e
File "/Users/kkom/.local/share/virtualenvs/optional_typeddict-hmzsbyx_/lib/python3.9/site-packages/typedload/dataloader.py" , line 290 , in load
return cast (T , func (self , value , type_ ))
File "/Users/kkom/.local/share/virtualenvs/optional_typeddict-hmzsbyx_/lib/python3.9/site-packages/typedload/dataloader.py" , line 500 , in _namedtupleload
raise TypedloadValueError (
typedload .exceptions .TypedloadValueError : Value does not contain fields : {'b' } which are necessary for type ExampleTypedDict
Path : .
PS: Here is my exact setup:
➜ optional_typeddict cat Pipfile
[[source] ]
url = " https://pypi.org/simple"
verify_ssl = true
name = " pypi"
[packages]
typedload = " ==2.7"
[dev-packages]
[requires]
python_version = " 3.9"
CC: @sid-at-github
Reactions are currently unavailable
Hey, I have a behaviour which I think is a bug / missing functionality.
Here is the code (using
typedload==2.7):And here is the result of running it:
PS: Here is my exact setup:
CC: @sid-at-github