-
Notifications
You must be signed in to change notification settings - Fork 192
Update user-facing variable names and add override checks for name, resources, and batch_size
#1223
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
Update user-facing variable names and add override checks for name, resources, and batch_size
#1223
Conversation
Signed-off-by: Sarah Yurick <[email protected]>
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.
Greptile Overview
Greptile Summary
Enforces proper configuration management by preventing subclasses from overriding name, resources, and batch_size properties.
Key changes:
- Added
@finaldecorator toname,resources, andbatch_sizeproperties for type checker enforcement - Implemented
__init_subclass__hook to raiseTypeErrorat class definition time if any subclass attempts to override these properties - These properties should only be modified through the
with_()method which updates internal_name,_resources, and_batch_sizeattributes
Rationale:
This change prevents developers from accidentally creating conflicting configuration patterns and ensures consistent usage of the with_() method for property overrides (see PR #764).
Confidence Score: 5/5
- This PR is safe to merge with no risk
- The change is a defensive programming improvement that enforces existing design constraints. The
__init_subclass__validation works correctly at class definition time, and testing confirms no existing subclasses override these properties. The@finaldecorator provides additional static type checking support. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| nemo_curator/stages/base.py | 5/5 | Added @final decorators and __init_subclass__ validation to enforce proper usage of name, resources, and batch_size properties |
Sequence Diagram
sequenceDiagram
participant Dev as Developer
participant Sub as Subclass Definition
participant Init as __init_subclass__
participant Base as ProcessingStage
Dev->>Sub: Define new subclass
Sub->>Init: Trigger __init_subclass__
Init->>Init: Check if 'name' in cls.__dict__
Init->>Init: Check if 'resources' in cls.__dict__
Init->>Init: Check if 'batch_size' in cls.__dict__
alt Property override detected
Init-->>Dev: Raise TypeError
else No override
Init->>Base: super().__init_subclass__()
Base-->>Dev: Subclass created successfully
end
Note over Dev,Base: Properties can only be modified via with_() method
1 file reviewed, no comments
Signed-off-by: Sarah Yurick <[email protected]>
No description provided.