-
Notifications
You must be signed in to change notification settings - Fork 3
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
Merge locals()
with globals()
for context in Python 3.13
#14
Conversation
Reviewer's Guide by SourceryThis pull request modifies the context generation in the No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
============================== warnings summary ===============================
tests/test_utils.py::test_accumulate
C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\asyncio\base_events.py:746: RuntimeWarning: coroutine method 'aclose' of 'accumulate_any.<locals>._' was never awaited
self._ready.clear()
Enable tracemalloc to get traceback where the object was allocated.
See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info =========================== |
✅ Deploy Preview for promplate-core ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @CNSeniorious000 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider breaking down the one-liner into multiple lines for improved readability.
- It would be helpful to add a brief comment explaining why the change is necessary for Python 3.13 and above.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Review instructions: all looks good
- 🟢 Testing: all looks good
- 🟢 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.
@@ -87,7 +88,8 @@ def _on_special_token(self, token, sync: bool): | |||
@staticmethod | |||
def _make_context(text: str): | |||
"""generate context parameter if specified otherwise use locals() by default""" | |||
|
|||
if version_info >= (3, 13): | |||
return f"globals() | locals() | dict({text[text.index(' ') + 1:]})" if " " in text else "globals() | locals()" | |||
return f"locals() | dict({text[text.index(' ') + 1:]})" if " " in text else "locals()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider refactoring the common condition if " " in text
to improve readability.
The condition is repeated in both the new and existing code. Extracting this logic could make the code more maintainable and reduce duplication.
@staticmethod
def _make_context(text: str):
"""generate context parameter if specified otherwise use locals() by default"""
has_extra_context = " " in text
if version_info >= (3, 13):
base_context = "globals() | locals()"
extra = f" | dict({text[text.index(' ') + 1:]})" if has_extra_context else ""
else:
base_context = "locals()"
extra = f" | dict({text[text.index(' ') + 1:]})" if has_extra_context else ""
return f"{base_context}{extra}"
a251596
to
1880ad2
Compare
locals()
with globals()
for context forwardinglocals()
with globals()
for context in Python 3.13
locals()
forwarding breaks in Python 3.13 #13Summary by Sourcery
Fix context generation by merging
locals()
withglobals()
for Python 3.13 and above, ensuring correct context forwarding.Bug Fixes:
locals()
withglobals()
when Python version is 3.13 or higher.