Skip to content

Conversation

@xelandernt
Copy link
Collaborator

@xelandernt xelandernt commented Mar 28, 2025

Resolves #181

@xelandernt xelandernt added this to the 3.0.0 milestone Mar 28, 2025
@xelandernt xelandernt requested a review from Copilot March 28, 2025 21:35
Copy link

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 extends the global context retrieval functionality by adding a raise_on_not_found flag to the fetch_context_item function and introducing a new function fetch_context_item_by_type to retrieve context items by their type.

  • Updated fetch_context_item signature to optionally raise a KeyError when a key isn’t found.
  • Added fetch_context_item_by_type function for type-based context retrieval.
  • Updated tests and documentation to reflect these new behaviors.

Reviewed Changes

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

File Description
that_depends/providers/context_resources.py Updated fetch_context_item and added fetch_context_item_by_type functionality
that_depends/init.py Updated imports to include the new fetch_context_item_by_type
tests/providers/test_context_resources.py Added tests for fetch_context_item_by_type and functionality for raise_on_not_found
docs/providers/context-resources.md Updated documentation to demonstrate usage of fetch_context_item_by_type

@codecov
Copy link

codecov bot commented Mar 28, 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/providers/test_context_resources.py 100.00% <100.00%> (ø)
that_depends/__init__.py 100.00% <100.00%> (ø)
that_depends/providers/context_resources.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xelandernt xelandernt changed the title 181 gc by type Fetch context item by type Mar 28, 2025
@lesnik512 lesnik512 merged commit 96567cc into v3 Mar 29, 2025
6 checks passed
@xelandernt xelandernt deleted the 181-gc-by-type branch March 30, 2025 12:19
xelandernt added a commit that referenced this pull request Apr 11, 2025
* Graph (#169)

* Removed redundant kwargs.

* Added SupportsTeardown API.

* Added test for local singleton.

* Added child self registration.

* Added tear_down propagation to children.

* Extended SupportsTeardown API.

* Made registration happen or resolution.

* Fixed some bugs and wrote tests for teardown.

* Tear down tests for containers

* Improved the injection documentation.

* Extended override API

* Removed limitations sections.

* Fixed async tear-down bug.

* Added tear-down documentation.

* Added tests for tear down during overriding.

* Added overriding during teardown documentation.

* Added container tear-down to documentation.

* Minor documentation fixes.

* Added async override methods. (#172)

* Changed override to sync_override.

* Added async overrides.

* Added tests for overrides.

* Renamed from sync_* to *_sync. (#176)

* Removed support for container_context(). (#175)

* Removed support for container_context().

* Added tests.

* Adjusted documentation.

* Fetch context item by type (#182)

* Added fetch_context_item_by_type

* Added documentation.

* Inject only enters scope for relevant providers. (#183)

* Correctly enter context for relevant provides when injecting.

* Correctly enter context for parent providers.

* Modified parent and child registration and implemented context initialization during injection.

* Removed redundant test file.

* Clarified unreachable location in comment.

* Re-added at runtime parent-child registration.

* Added asyncio lock.

* Adjusted some issues and made test order random.

* Fixed pr comments.

* Renamed override_context, extended scope documentation and wrote the migration guide for v3.

* Fixed >>>.

* Refactored injection to improve performance.

* Fixed incorrect api. Added benchmarks.

* Added 3.0.0.a1 results.

* Added 2.2.0 results.

* Fixed api naming in Container.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants