-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add missing functools.wraps
decorator to deprecated
decorator and handle dataclass
properly
#699
Add missing functools.wraps
decorator to deprecated
decorator and handle dataclass
properly
#699
Conversation
Warning Rate limit exceeded@DanielYang59 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 22 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe recent changes enhance the handling of deprecated functions and classes throughout the codebase. They improve metadata preservation through decorators, adopt more precise type annotations, and refine documentation practices. These modifications aim to modernize the code, ensuring clarity and maintainability while preserving existing functionality. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DeprecatedFunction
participant Documentation
User->>DeprecatedFunction: Call deprecated function
DeprecatedFunction->>Documentation: Log deprecation warning
Documentation-->>User: Provide function metadata
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- src/monty/dev.py (3 hunks)
- src/monty/json.py (7 hunks)
- tests/test_dev.py (3 hunks)
Additional comments not posted (11)
tests/test_dev.py (4)
22-22
: Good addition of docstring.The docstring improves the documentation of the
func_old
function.
32-34
: Good addition of metadata preservation checks.The assertions ensure that the function's name and docstring are preserved.
120-120
: Good update to class docstring.The updated docstring provides clearer context for
TestClassOld
.
125-136
: Good addition of docstring and metadata preservation checks.The docstring improves the documentation of the
method_b
function. The assertions ensure that the class's docstring, attribute, and module name are preserved.src/monty/dev.py (3)
125-125
: Good use offunctools.wraps
to preserve metadata.The addition of
functools.wraps
ensures that the metadata of the original function is preserved.
134-140
: Good refinement of dataclass initialization logic.The refined logic ensures that the warning message is issued appropriately when a dataclass is instantiated.
146-150
: Good handling of__post_init__
and__init__
methods for dataclasses.The change ensures that the appropriate method is modified for dataclasses, improving the usability and clarity of the deprecation warnings.
src/monty/json.py (4)
177-177
: Good update to type hint for dictionary variable.The updated type hint enhances type specificity, making the code clearer and more consistent with modern Python type hinting practices.
240-245
: Good revision of docstring formatting.The revised docstring formatting improves the readability and structure of the documentation.
554-555
: Good addition of type hints to constructor parameters.The added type hints improve type safety and clarity.
558-558
: Good update to type hint for_name_object_map
variable.The updated type hint enhances type specificity, making the code clearer and more consistent with modern Python type hinting practices.
functools.wraps
decorator to deprecated
decoratorfunctools.wraps
decorator to deprecated
decorator and handle dataclass
properly
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #699 +/- ##
==========================================
- Coverage 80.93% 80.76% -0.17%
==========================================
Files 27 27
Lines 1563 1570 +7
Branches 353 357 +4
==========================================
+ Hits 1265 1268 +3
- Misses 234 236 +2
- Partials 64 66 +2 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/test_dev.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/test_dev.py
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/test_dev.py (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/test_dev.py
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/monty/json.py (7 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/monty/json.py
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/monty/dev.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/monty/dev.py
This reverts commit f68d9e9.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/monty/dev.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/monty/dev.py
@shyuep Can you please review this? Thanks. |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/test_dev.py (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/test_dev.py
try: | ||
import dataclasses | ||
except ImportError: | ||
dataclasses = None # type: ignore |
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.
I think it's safe to remove guard for dataclasses
now.
Added in version 3.7.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/monty/json.py (8 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/monty/json.py
Summary
functools.wraps
decorator todeprecated
decorator to ensure metadata is passed correctlydataclass
properly, as suggested in Transition to pymatgen VASP input sets materialsproject/atomate2#854 (comment)mypy
errors injson
moduleSummary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Documentation