Skip to content
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

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

Open
JacobCoffee opened this issue Oct 11, 2024 · 0 comments
Labels
enhancement ➕ This is a brand new feature or request good first issue 🥈 Good for newcomers help wanted 🆘 Extra attention is needed

Comments

@JacobCoffee
Copy link
Owner

JacobCoffee commented Oct 11, 2024

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)


Note

We utilize Polar.sh to engage in regular as well as pledge-based > sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@JacobCoffee JacobCoffee added enhancement ➕ This is a brand new feature or request help wanted 🆘 Extra attention is needed good first issue 🥈 Good for newcomers labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ➕ This is a brand new feature or request good first issue 🥈 Good for newcomers help wanted 🆘 Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant