Skip to content

Allow sync in async factories#197

Merged
xelandernt merged 5 commits into
mainfrom
allow-sync-in-async-factories
Aug 18, 2025
Merged

Allow sync in async factories#197
xelandernt merged 5 commits into
mainfrom
allow-sync-in-async-factories

Conversation

@xelandernt
Copy link
Copy Markdown
Collaborator

Resolves #196

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 17, 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_factories.py 100.00% <100.00%> (ø)
that_depends/providers/collection.py 100.00% <ø> (ø)
that_depends/providers/context_resources.py 100.00% <ø> (ø)
that_depends/providers/factories.py 100.00% <100.00%> (ø)
that_depends/providers/local_singleton.py 100.00% <ø> (ø)
that_depends/providers/object.py 100.00% <ø> (ø)
that_depends/providers/resources.py 100.00% <ø> (ø)
that_depends/providers/selector.py 100.00% <ø> (ø)
that_depends/providers/singleton.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xelandernt xelandernt requested a review from Copilot August 17, 2025 14:27
Copy link
Copy Markdown

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 resolves issue #196 by enabling AsyncFactory to accept both synchronous and asynchronous factory functions, while maintaining backward compatibility. The changes also update documentation and docstrings to reflect the new method naming conventions.

  • Updates AsyncFactory to accept both sync and async factory functions using method overloads
  • Adds runtime detection using inspect.isawaitable() to handle both sync and async factories appropriately
  • Updates documentation and comments to use the new method names (resolve() and resolve_sync())

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
that_depends/providers/factories.py Core implementation allowing sync factories in AsyncFactory with overloaded constructors and runtime awaitable detection
tests/providers/test_factories.py New test cases verifying AsyncFactory works with sync creators and dependency injection
docs/providers/factories.md Updated documentation explaining AsyncFactory now supports both sync and async creators
that_depends/providers/singleton.py Updated docstring examples and comments to use new method names
that_depends/providers/selector.py Updated docstring examples to use new method names
that_depends/providers/resources.py Updated docstring examples to use new method names
that_depends/providers/object.py Updated docstring examples to use new method names
that_depends/providers/local_singleton.py Updated docstring examples to use new method names
that_depends/providers/context_resources.py Updated docstring examples to use new method names
that_depends/providers/collection.py Updated docstring examples to use new method names

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread that_depends/providers/factories.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@xelandernt xelandernt marked this pull request as ready for review August 17, 2025 14:30
@xelandernt xelandernt self-assigned this Aug 18, 2025
@xelandernt xelandernt added the enhancement New feature or request label Aug 18, 2025
@xelandernt xelandernt merged commit 2a8b48f into main Aug 18, 2025
6 checks passed
@xelandernt xelandernt deleted the allow-sync-in-async-factories branch August 19, 2025 07:16
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.

Allow AsyncFactory provider to resolve sync creators.

2 participants