-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Model Factory #16
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
base: master
Are you sure you want to change the base?
Conversation
| from abc import ABC, abstractmethod | ||
| import copy | ||
|
|
||
| # Type variables for our factory system |
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.
Redundant comment that just states what the code itself makes clear via the TypeVar declaration. The comment adds no additional context or explanation beyond what is immediately apparent from the code.
🔍 This comment matches your effective_comments.mdc rule.
| # Type variables for our factory system |
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
|
|
||
| def __init__(self, schema: ModelSchema): | ||
| self.schema = schema | ||
| # Cache for generated models to avoid regeneration |
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.
Comment restates what is obvious from the variable names and initialization pattern. The fact that these are caches for generated models is clear from the '_model' suffix and None initialization. The comment adds no extra insight.
🔍 This comment matches your effective_comments.mdc rule.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
| if field_name in ['hashed_password', 'password']: | ||
| return None | ||
|
|
||
| # Apply standard field constraints |
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.
Redundant comment that simply labels the next block of code without adding any valuable context. The code itself clearly shows that standard field constraints are being applied through self-documenting variable names.
🔍 This comment matches your effective_comments.mdc rule.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
| from .model_factory import ModelFactoryRegistry, setup_model_factories | ||
|
|
||
| # Initialize the factory system and generate all entity models | ||
| setup_model_factories() |
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.
Premature abstraction introducing a complex factory pattern that couples behaviors which may need to evolve separately. The factory system enforces a rigid CRUD pattern across all models, making it difficult to handle domain-specific variations in validation rules, update patterns, and business constraints. According to the anti-DRY principle, this abstraction should wait until clear common patterns emerge that justify the coupling.
🔍 This comment matches your anti_dry.mdc rule.
| setup_model_factories() | |
| class UserBase(SQLModel): | |
| email: EmailStr = Field(unique=True, index=True, max_length=255) | |
| is_active: bool = True | |
| is_superuser: bool = False | |
| full_name: str | None = Field(default=None, max_length=255) |
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
| user_models = ModelFactoryRegistry.get_all_models_for("User") | ||
| item_models = ModelFactoryRegistry.get_all_models_for("Item") | ||
|
|
||
| # Factory-generated User models |
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.
Redundant comment that simply restates what is already obvious from the code and variable names. The comment adds no additional context or explanation of why the factory pattern is used, violating the principle that comments should explain why, not what.
🔍 This comment matches your effective_comments.mdc rule.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
| UserPublic = user_models['public'] | ||
| UsersPublic = user_models['list_public'] | ||
|
|
||
| # Factory-generated Item models |
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.
Redundant comment that merely restates what is clear from the variable names and code structure. Comments should not state the obvious but rather provide insight into non-obvious aspects of the code.
🔍 This comment matches your effective_comments.mdc rule.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
| ItemPublic = item_models['public'] | ||
| ItemsPublic = item_models['list_public'] | ||
|
|
||
| # Non-factory models that don't fit the standard CRUD pattern |
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.
Redundant comment that provides no additional context beyond what's already clear from the code structure and naming. The fact that these models don't use the factory pattern is evident from the code itself.
🔍 This comment matches your effective_comments.mdc rule.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
|
😱 Found 8 issues. Time to roll up your sleeves! 😱 Need help? Join our Discord for support! |
No description provided.