Skip to content

Enhancement: Refactor the UpdateableGuildSetting class into smaller, more focused classes.Β #89

@JacobCoffee

Description

@JacobCoffee

issue (complexity): Consider refactoring the UpdateableGuildSetting class into smaller, more focused classes.

The changes introduce more structured configuration options, which is good for maintainability. However, the UpdateableGuildSetting class has become overly complex with too many responsibilities. Consider splitting it into smaller, more focused classes:

class BaseGuildSetting(CamelizedBaseModel):
    """Base class for guild settings."""
    guild_id: UUID

class GuildModelSetting(BaseGuildSetting):
    """Settings for the guild model."""
    prefix: str
    help_channel_id: int
    showcase_channel_id: int
    sync_label: str
    issue_linking: bool
    comment_linking: bool
    pep_linking: bool

class GitHubConfigSetting(BaseGuildSetting):
    """Settings for GitHub configuration."""
    discussion_sync: bool
    github_organization: str
    github_repository: str

# Similar classes for StackOverflow, AllowedUsers, and Forum configs

class UpdateableGuildSetting(CamelizedBaseModel):
    """Allowed settings that admins can update for their guild."""
    guild_model: GuildModelSetting
    github_config: GitHubConfigSetting
    # Other config classes...

This approach maintains the structured configs while reducing complexity. It also eliminates the need for the dynamic enum creation method, which adds unnecessary abstraction. If you need an enum of all possible settings, consider creating it explicitly:

class GuildSettingField(StrEnum):
    PREFIX = "prefix"
    HELP_CHANNEL_ID = "help_channel_id"
    # ... other fields ...

This change will make the code more maintainable and easier to understand while preserving the new functionality.

Originally posted by @sourcery-ai[bot] in #87 (comment)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions