Conversation
There was a problem hiding this comment.
Pull Request Overview
Introduce a new @asfunction decorator that converts injectable classes with a __call__ method into standalone functions.
- Add the
asfunctiondecorator implementation and register it in the module API - Provide type stubs and overloads for proper typing support
- Include tests and documentation demonstrating sync/async use cases and integration guide
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/core/test_asfunction.py | Add tests covering sync and async uses of the new @asfunction |
| injection/_core/asfunction.py | Implement the asfunction decorator logic |
| injection/init.pyi | Add overload signatures for asfunction in the type stub |
| injection/init.py | Export asfunction in the public API |
| documentation/integrations/unlisted-framework.md | Document how to use asfunction with unlisted frameworks |
| README.md | Link the new unlisted-framework integration guide |
Comments suppressed due to low confidence (2)
tests/core/test_asfunction.py:1
- There’s no test covering the
threadsafe=Trueflag onasfunction. Consider adding a test that uses@asfunction(module=module, threadsafe=True)to verify thread-safe behavior.
from typing import NamedTuple
injection/_core/asfunction.py:10
- The generic parameters P and T are not defined or imported. Import ParamSpec and TypeVar from typing and add
P = ParamSpec('P')andT = TypeVar('T')before this function so the annotations resolve correctly.
def asfunction[**P, T](
added 2 commits
June 7, 2025 13:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.