You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromdependency_injectorimportcontainers, providersfrompydantic_settingsimportBaseSettingsclassContainer(containers.DeclarativeContainer):
config=providers.Configuration()
# This one will work:classOverriddeContainer(Container):
config=providers.Configuration(
default={"foo": "bar"}
)
classConfig(BaseSettings):
bla: str="nja"classContainer2(containers.DeclarativeContainer):
config=providers.Configuration(pydantic_settings=[Config()])
# this one will work:@containers.copy(Container2)classOverriddeContainer2(Container2):
config2=providers.Configuration(
pydantic_settings=[Config(bla="foo")]
)
# this one will fail:@containers.copy(Container2)classOverriddeContainer3(Container2):
config=providers.Configuration(
pydantic_settings=[Config(bla="foo")]
)
Error thrown:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/milos/projects/di-test/src/ditest/__main__.py", line 32, in<module>
@containers.copy(Container2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "src/dependency_injector/containers.pyx", line 871, in dependency_injector.containers.copy._decorator
File "src/dependency_injector/containers.pyx", line 865, in dependency_injector.containers.copy._get_memo_for_matching_names
File "src/dependency_injector/containers.pyx", line 858, in dependency_injector.containers.copy._get_memo_for_matching_names
TypeError: 'NoneType' object is not iterable
Thought you might want to know.
Love the library btw.
EDIT:
Tried to mess with Cython magic a bit, but this is a bit too much for me at the moment. The best I was able to do is:
...which makes it work:
...but I'm not really confident this would be a right solution, looks like the error could be something deeper.
The text was updated successfully, but these errors were encountered:
glendza
changed the title
C
Copying a container fails if a pydantic-settings configuration is overriden
Feb 11, 2025
glendza
changed the title
Copying a container fails if a pydantic-settings configuration is overriden
Copying a container fails if a pydantic-settings-based configuration is overridden
Feb 11, 2025
Package versions:
Example code:
Error thrown:
Thought you might want to know.
Love the library btw.
EDIT:
Tried to mess with Cython magic a bit, but this is a bit too much for me at the moment. The best I was able to do is:
...which makes it work:
...but I'm not really confident this would be a right solution, looks like the error could be something deeper.
The text was updated successfully, but these errors were encountered: