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

4.8.2 broke different case for providers.Container usage where declaration is not at class root level #379

Closed
rmk135 opened this issue Jan 27, 2021 · 3 comments
Assignees
Labels

Comments

@rmk135
Copy link
Member

rmk135 commented Jan 27, 2021

Instead of opening new issue I'll comment right here, because 4.8.2 broke different case for providers.Container usage where declaration is not at class root level.

Here is somewhat simplified example:

from dependency_injector import providers, containers


class NestedContainer(containers.DeclarativeContainer):
	settings = providers.Configuration()

	print_settings = providers.Callable(
		lambda s: print(s),
		settings,
	)


class TestContainer(containers.DeclarativeContainer):
	settings = providers.Configuration()

	root_container = providers.Container(
		NestedContainer,
		settings=settings,
	)

	not_root_container = providers.Selector(
		settings.container,
		using_factory=providers.Factory(
			NestedContainer,
			settings=settings,
		),
		using_container=providers.Container(
			NestedContainer,
			settings=settings,
		)
	)


container = TestContainer(settings=dict(
	container='using_factory',
	foo='bar'
))

container.root_container().print_settings()  # Prints {'container': 'using_factory', 'foo': 'bar'}
container.not_root_container().print_settings()  # Prints {'container': 'using_factory', 'foo': 'bar'}

container = TestContainer(settings=dict(
	container='using_container',
	foo='bar'
))

container.root_container().print_settings()  # Prints {'container': 'using_container', 'foo': 'bar'}
container.not_root_container().print_settings()  # Prints {} after 4.8.2

We expect here for all prints to be equal, and 4.8.2 breaks it. Workaround is using providers.Factory, but still case is some kind of a regression.

Originally posted by @approxit in #354 (comment)

@rmk135 rmk135 changed the title 4.8.2 broke different case for providers.Container` usage where declaration is not at class root level 4.8.2 broke different case for providers.Container usage where declaration is not at class root level Jan 27, 2021
@rmk135 rmk135 self-assigned this Jan 27, 2021
@rmk135 rmk135 added the bug label Jan 27, 2021
@rmk135 rmk135 changed the title 4.8.2 broke different case for providers.Container usage where declaration is not at class root level 4.8.2 broke different case for providers.Container usage where declaration is not at class root level Jan 27, 2021
@rmk135
Copy link
Member Author

rmk135 commented Jan 27, 2021

Fixed in 4.11.2. CD is publishing it on PyPI: https://github.com/ets-labs/python-dependency-injector/actions/runs/516012732.

Should be available in ~30 minus.

@approxit
Copy link

Thanks for instant reaction! Now everything works as intended. :)

@rmk135
Copy link
Member Author

rmk135 commented Jan 27, 2021

Good, glad to hear. Thanks for reporting the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants