python-dependency-injector/tests/typing/container.py
Leonardus Chen 13847c0ce6
Retrofit assert type for some type-stub checks (#943)
Retrofit assert type for:

- configuration.py
- container.py
- declarative_container.py
- delegate.py
- dependencies_container.py
- dependency.py
- dict.py
- dynamic_container.py
2026-01-31 15:34:10 +02:00

20 lines
400 B
Python

from typing import Any
from typing_extensions import assert_type
from dependency_injector import providers
class Container: ...
# Test 1: to check the return type
provider1 = providers.Container(Container)
var1 = provider1()
assert_type(var1, Container)
# Test 2: to check the getattr
provider2 = providers.Container(Container)
attr = provider2.attr
assert_type(attr, providers.Provider[Any])