fix: replace KeyError with warning for duplicate registration#7
fix: replace KeyError with warning for duplicate registration#7Tohrusky merged 1 commit intoEutropicAI:mainfrom
Conversation
Summary of ChangesHello @Tohrusky, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the object registration process within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request changes the behavior for duplicate object registration from raising a KeyError to issuing a UserWarning. This makes the registration process more lenient and less strict. The implementation is mostly correct, but I've suggested an improvement to the warning's stacklevel to make it more useful for developers by pointing to their code that caused the duplicate registration, rather than internal library code.
| warnings.warn( | ||
| f"[CCCV] An object named '{name}' was already registered in '{self._name}' registry! We will NOT overwrite the existing one.", | ||
| UserWarning, | ||
| stacklevel=2, | ||
| ) |
There was a problem hiding this comment.
The current stacklevel=2 will cause the warning to point to the register method within this file, which is not very helpful for the end-user. To make the warning more useful, it should point to the line in the user's code where the duplicate registration is attempted. Changing stacklevel to 3 will achieve this by moving up the call stack to the user's code, making it much easier to locate the source of the duplicate registration.
| warnings.warn( | |
| f"[CCCV] An object named '{name}' was already registered in '{self._name}' registry! We will NOT overwrite the existing one.", | |
| UserWarning, | |
| stacklevel=2, | |
| ) | |
| warnings.warn( | |
| f"[CCCV] An object named '{name}' was already registered in '{self._name}' registry! We will NOT overwrite the existing one.", | |
| UserWarning, | |
| stacklevel=3, | |
| ) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7 +/- ##
=======================================
Coverage 92.61% 92.62%
=======================================
Files 40 40
Lines 1219 1220 +1
=======================================
+ Hits 1129 1130 +1
Misses 90 90 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.