NoCache class requires parentheses for decorator, unlike Cache#20
NoCache class requires parentheses for decorator, unlike Cache#20leshchenko1979 merged 3 commits intomasterfrom
Conversation
Reviewer's Guide by SourceryThis PR modifies the NoCache class to support both decorator syntaxes - with and without parentheses (@cache and @cache()). The implementation changes the call method from a staticmethod to an instance method and introduces a new _decorator method to handle the function wrapping logic. Sequence diagram for NoCache decorator usagesequenceDiagram
actor User
participant NoCache
participant Function
User->>NoCache: Apply @cache or @cache() decorator
NoCache->>NoCache: __call__(*decorator_args, **decorator_kwargs)
alt With parentheses
NoCache->>NoCache: _decorator(fn)
else Without parentheses
NoCache->>NoCache: _decorator(fn)
end
NoCache->>Function: Wrap function
User->>Function: Call decorated function
Function-->>User: Return result
Updated class diagram for NoCache classclassDiagram
class NoCache {
+__call__(*decorator_args, **decorator_kwargs)
+_decorator(fn)
+cache
}
note for NoCache "The __call__ method is now an instance method and can handle both @cache and @cache() syntaxes."
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @leshchenko1979 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟡 Testing: 2 issues found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| """ | ||
| if decorator_args and callable(decorator_args[0]): | ||
| return self._decorator(decorator_args[0]) | ||
| return self._decorator |
There was a problem hiding this comment.
issue (bug_risk): Decorator kwargs are not forwarded to _decorator when used as a parameterized decorator
When used as a parameterized decorator, decorator_kwargs are lost. Consider passing them through: return lambda fn: self._decorator(fn, **decorator_kwargs)
leshchenko1979
left a comment
There was a problem hiding this comment.
@sourcery-ai review
Fixes #19
Summary by Sourcery
Fix the NoCache class to support usage as a decorator with or without parentheses and add corresponding tests to ensure correct functionality.
Bug Fixes:
Tests: