I'm not sure whether this is intended behavior or not. In the following example I'd expect make_resource function to receive a Resource.
from typing import Callable
from pydantic.main import BaseModel
import thinc
from thinc.api import Config, registry
class Resource(BaseModel):
url: str
thinc.registry.create("resources")
@thinc.registry.resources("Resource.v1")
def make_resource(
resource: Resource,
) -> str:
return resource.url # this fails since resource is a dict and not Resource
config = Config().from_str(
"""
[test]
@resources = "Resource.v1"
[test.resource]
url = "https://thinc.ai/docs/usage-config"
"""
)
resolved = registry.resolve(config)
But the current registry.resolve simply validates that a dict would be able to be parsed to Resource but is not actually resolved to a Resource, i.e. the type in make_resource is a dict in the example above so I end up with the following error
AttributeError: 'dict' object has no attribute 'url'
Now obviously the validation should pass but I think the dict should be casted into the given BaseModel as well so the typings in the registered functions can be trusted.
I imagine this is related to #57 and #59
I'm not sure whether this is intended behavior or not. In the following example I'd expect
make_resourcefunction to receive aResource.But the current
registry.resolvesimply validates that adictwould be able to be parsed toResourcebut is not actually resolved to aResource, i.e. the type inmake_resourceis adictin the example above so I end up with the following errorNow obviously the validation should pass but I think the dict should be casted into the given
BaseModelas well so the typings in the registered functions can be trusted.I imagine this is related to #57 and #59