Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion modern_di/exceptions/registration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Errors reporting declaration mistakes, detected at declaration time or by ``validate()``."""

import abc
import enum
import typing

Expand Down Expand Up @@ -199,7 +200,6 @@ class _DependencyChainError(RegistrationError):
"""

_chain_headline: typing.ClassVar[str]
_message: typing.Callable[[], str]

__slots__ = ("dependency_chain", "parameter_name", "provider")

Expand All @@ -215,6 +215,9 @@ def __init__(
self.dependency_chain = dependency_chain
super().__init__(self._message())

@abc.abstractmethod
def _message(self) -> str: ...

@property
def dependency_provider(self) -> "AbstractProvider[typing.Any]":
"""The dependency as declared: the type the parameter is annotated with."""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_resolver_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,8 @@ def test_compile_resolver_rejects_an_unknown_provider_type() -> None:
"""

class _Unsupported(AbstractProvider[int]):
__module__ = "modern_di.providers.unsupported" # an internal type, which may subclass
# an internal type, which may subclass
__module__ = "modern_di.providers.unsupported" # ty: ignore[invalid-mutable-override]
__slots__ = ()

with pytest.raises(TypeError, match="no compiled resolver for provider type _Unsupported"):
Expand Down
Loading