From 3fe6c9dca0a6016ea89febe1bb851a3045ce7057 Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Wed, 14 Oct 2026 17:04:28 +0300 Subject: [PATCH] fix: make _DependencyChainError._message abstract for ty 0.0.87 --- modern_di/exceptions/registration.py | 5 ++++- tests/test_resolver_compiler.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modern_di/exceptions/registration.py b/modern_di/exceptions/registration.py index bdf3c842..1e5477b2 100644 --- a/modern_di/exceptions/registration.py +++ b/modern_di/exceptions/registration.py @@ -1,5 +1,6 @@ """Errors reporting declaration mistakes, detected at declaration time or by ``validate()``.""" +import abc import enum import typing @@ -199,7 +200,6 @@ class _DependencyChainError(RegistrationError): """ _chain_headline: typing.ClassVar[str] - _message: typing.Callable[[], str] __slots__ = ("dependency_chain", "parameter_name", "provider") @@ -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.""" diff --git a/tests/test_resolver_compiler.py b/tests/test_resolver_compiler.py index 02c142a3..f683f5d6 100644 --- a/tests/test_resolver_compiler.py +++ b/tests/test_resolver_compiler.py @@ -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"):