Skip to content
New issue

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

Improve descriptor error messages #340

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alluka/_self_injecting.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


class AsyncSelfInjecting(alluka.AsyncSelfInjecting[_CallbackSigT]):
"""Class used to link a sync function to a client to make it self-injecting.
"""Class used to link an async function to a client to make it self-injecting.

Examples
--------
Expand Down
7 changes: 7 additions & 0 deletions alluka/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"""Internal types used by Alluka."""
from __future__ import annotations

from typing import Any

__all__: list[str] = ["Injected", "InjectedDescriptor"]

import enum
Expand Down Expand Up @@ -256,6 +258,11 @@ def __init__(
self.callback = callback
self.type = type

def __getattr__(self, __name: str) -> Any:
hypergonial marked this conversation as resolved.
Show resolved Hide resolved
raise AttributeError(
"Tried accessing a parameter that was not injected yet. Did you forget to inject dependencies?"
)


Injected = typing.Annotated[_T, InjectedTypes.TYPE]
"""Type alias used to declare a keyword argument as requiring an injected type.
Expand Down
Loading