We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With the upcoming version 5 of Asphalt, one cannot set the type of a resource to e.g. a typing.Callable anymore, while it worked fine with version 4.
typing.Callable
from typing import Callable from asphalt.core import CLIApplicationComponent, Component, Context, run_application def resource() -> str: return "resource" class Subcomponent0(Component): async def start(self, ctx: Context): ctx.add_resource(resource, types=Callable[[], str]) class Component0(CLIApplicationComponent): async def start(self, ctx: Context): self.add_component("subcomponent0", Subcomponent0) await super().start(ctx) async def run(self, ctx: Context): res = await ctx.request_resource(Callable[[], str]) print(f"{res=}") run_application(Component0())
The following is printed:
res=<function resource at 0x7f33fa7d1440>
from typing import Callable from asphalt.core import Component, add_resource, get_resource, run_application def resource() -> str: return "resource" class Subcomponent0(Component): async def start(self): add_resource(resource, types=Callable[[], str]) class Component0(Component): def __init__(self): self.add_component("subcomponent0", Subcomponent0) async def start(self): res = await get_resource(Callable[[], str]) print(f"{res=}") run_application(Component0)
The following error is raised:
asphalt.core.ComponentStartError: error starting component 'subcomponent0' (__main__.Subcomponent0): TypeError: '_CallableGenericAlias' object is not iterable
The text was updated successfully, but these errors were encountered:
No branches or pull requests
With the upcoming version 5 of Asphalt, one cannot set the type of a resource to e.g. a
typing.Callable
anymore, while it worked fine with version 4.The following is printed:
The following error is raised:
The text was updated successfully, but these errors were encountered: