Skip to content

enter_scope when using @inject. #189

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

Merged
merged 16 commits into from
May 6, 2025
Merged

enter_scope when using @inject. #189

merged 16 commits into from
May 6, 2025

Conversation

alexanderlazarev0
Copy link
Collaborator

No description provided.

@alexanderlazarev0 alexanderlazarev0 self-assigned this May 5, 2025
@alexanderlazarev0 alexanderlazarev0 added the enhancement New feature or request label May 5, 2025
@alexanderlazarev0
Copy link
Collaborator Author

To-do:

  • Documentation
  • Update migration guide.

Copy link

codecov bot commented May 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tests/test_injection.py 100.00% <100.00%> (ø)
that_depends/injection.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexanderlazarev0 alexanderlazarev0 marked this pull request as ready for review May 6, 2025 22:18
@alexanderlazarev0 alexanderlazarev0 requested a review from Copilot May 6, 2025 22:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces an "enter_scope" parameter to the dependency injection decorator, allowing the injected function to automatically enter the specified context. Key changes include updating the injection logic in injection.py, adjusting tests to cover new behavior for synchronous, asynchronous, and generator functions, and revising documentation to reflect the new usage.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
that_depends/injection.py Added the "enter_scope" parameter and corresponding error checks in the injection logic.
tests/test_injection.py Updated and added new tests to verify the behavior of the "enter_scope" flag.
docs/migration/v3.md Updated migration instructions to use "enter_scope=True" instead of the former container_context pattern.
docs/introduction/scopes.md Revised documentation to clarify that the scope is not entered by default.

@alexanderlazarev0 alexanderlazarev0 merged commit fdcb515 into main May 6, 2025
5 checks passed
@alexanderlazarev0 alexanderlazarev0 deleted the dev branch May 6, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant