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

refactor: move all enums in a dedicated module #515

Closed
wants to merge 4 commits into from
Closed

Conversation

clementb49
Copy link
Collaborator

@clementb49 clementb49 commented Feb 2, 2025

Summary by CodeRabbit

  • Refactor
    • Standardized and centralized configuration options, message roles, update modes, and media types used throughout the application. These updates ensure consistency across account dialogs, conversation views, hotkey actions, and other UI components.
  • Chores
    • Removed deprecated identifiers and streamlined internal references.
  • Tests
    • Adjusted test setups to align with the new centralized options.

Copy link
Contributor

coderabbitai bot commented Feb 2, 2025

Walkthrough

This pull request refactors the codebase by replacing legacy enumeration definitions and import sources with a consolidated set of enums from the new basilisk/enums module. Several obsolete enums (e.g., AccountSource, AutomaticUpdateModeEnum, KeyStorageMethodEnum, LogLevelEnum, ReleaseChannelEnum, MessageRoleEnum, HotkeyAction, etc.) and related functions have been removed. The changes update type annotations, import statements, and label retrieval across configuration, conversation, GUI, provider engines, and tests to improve consistency within the codebase.

Changes

File(s) Change Summary
basilisk/config/*
__init__.py, account_config.py, config_enums.py, main_config.py
Removed legacy enums and helper function exports; replaced enum types (e.g., KeyStorageMethodEnum, AutomaticUpdateModeEnum, etc.) with new enums from basilisk/enums and updated type annotations/imports accordingly.
basilisk/consts.py Removed the HotkeyAction enum.
basilisk/conversation/*
__init__.py, conversation_helper.py, conversation_model.py, image_model.py
Removed or replaced MessageRoleEnum and ImageFileTypes definitions with imports from basilisk/enums; updated references in message and attachment handling.
basilisk/enums.py Introduced new, centralized enums for configuration settings, message roles, key storage methods, logging levels, release channels, provider capabilities, capture and search modes, and more.
basilisk/gui/*
account_dialog.py, conversation_tab.py, main_frame.py, preferences_dialog.py, search_dialog.py
Updated GUI components to use new enums (e.g., KeyStorageMethod, AccountSource, MessageRole, HotkeyAction, CaptureMode, etc.) with adjustments to label retrieval and role assignments.
basilisk/main_app.py, message_segment_manager.py, tests/test_message_position_manager.py Updated imports to remove local enum definitions (e.g., local MessageSegmentType) and use the consolidated enums from basilisk/enums.
basilisk/provider*
(provider.py, provider_capability.py) and basilisk/provider_engine/*
(anthropic_engine.py, base_engine.py, deepseek_engine.py, gemini_engine.py, mistralai_engine.py, openai_engine.py, openrouter_engine.py, xai_engine.py)
Removed local definitions (e.g., ProviderAPIType, ProviderCapability, MessageRoleEnum) and updated imports to reference new enums from basilisk/enums; modified message role assignments in engine methods accordingly.
basilisk/screen_capture_thread.py, server_thread.py, updater.py Replaced local definitions of CaptureMode and ReleaseChannel enums with imports from basilisk/enums, adjusting related conditional checks and error handling.

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (1)
basilisk/enums.py (1)

152-161: Consider using IntFlag for SearchMode.

Since SearchMode uses integer values and could potentially be combined (e.g., PLAIN_TEXT | EXTENDED), consider using IntFlag instead of Enum.

-class SearchMode(Enum):
+class SearchMode(IntFlag):
     PLAIN_TEXT = 0
     EXTENDED = 1
     REGEX = 2
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1dfd67a and 0ec248e.

📒 Files selected for processing (31)
  • basilisk/config/__init__.py (0 hunks)
  • basilisk/config/account_config.py (8 hunks)
  • basilisk/config/config_enums.py (0 hunks)
  • basilisk/config/main_config.py (2 hunks)
  • basilisk/consts.py (0 hunks)
  • basilisk/conversation/__init__.py (1 hunks)
  • basilisk/conversation/conversation_helper.py (1 hunks)
  • basilisk/conversation/conversation_model.py (1 hunks)
  • basilisk/conversation/image_model.py (1 hunks)
  • basilisk/enums.py (1 hunks)
  • basilisk/gui/account_dialog.py (3 hunks)
  • basilisk/gui/conversation_tab.py (6 hunks)
  • basilisk/gui/main_frame.py (1 hunks)
  • basilisk/gui/preferences_dialog.py (3 hunks)
  • basilisk/gui/search_dialog.py (1 hunks)
  • basilisk/main_app.py (3 hunks)
  • basilisk/message_segment_manager.py (1 hunks)
  • basilisk/provider.py (1 hunks)
  • basilisk/provider_capability.py (0 hunks)
  • basilisk/provider_engine/anthropic_engine.py (2 hunks)
  • basilisk/provider_engine/base_engine.py (1 hunks)
  • basilisk/provider_engine/deepseek_engine.py (2 hunks)
  • basilisk/provider_engine/gemini_engine.py (3 hunks)
  • basilisk/provider_engine/mistralai_engine.py (1 hunks)
  • basilisk/provider_engine/openai_engine.py (2 hunks)
  • basilisk/provider_engine/openrouter_engine.py (1 hunks)
  • basilisk/provider_engine/xai_engine.py (1 hunks)
  • basilisk/screen_capture_thread.py (1 hunks)
  • basilisk/server_thread.py (1 hunks)
  • basilisk/updater.py (2 hunks)
  • tests/test_message_position_manager.py (1 hunks)
💤 Files with no reviewable changes (4)
  • basilisk/consts.py
  • basilisk/config/init.py
  • basilisk/provider_capability.py
  • basilisk/config/config_enums.py
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_app / build_windows (x86)
  • GitHub Check: build_app / build_windows (x64)
🔇 Additional comments (44)
basilisk/conversation/__init__.py (1)

2-2: LGTM! Clean removal of MessageRoleEnum.

The changes align with the PR objective of moving enums to a dedicated module. The removal of MessageRoleEnum from both the import statement and __all__ list is consistent with the broader transition to use MessageRole from basilisk.enums.

Also applies to: 5-14

basilisk/provider_engine/xai_engine.py (1)

4-7: LGTM! Clean transition to use ProviderCapability from basilisk.enums.

The changes align with the PR objective. The import and usage of ProviderCapability enum in the capabilities attribute is correct.

Also applies to: 13-16

basilisk/conversation/conversation_model.py (1)

8-8: LGTM! Clean transition to use MessageRole from basilisk.enums.

The changes align with the PR objective. The import of MessageRole and the type update in the Message class are correct.

Also applies to: 16-16

basilisk/screen_capture_thread.py (1)

11-11: LGTM! Clean transition to use CaptureMode from basilisk.enums.

The changes align with the PR objective. The import and usage of CaptureMode enum is correct.

basilisk/provider_engine/openrouter_engine.py (1)

9-9: LGTM! Import change aligns with enum centralization.

The change to import ProviderCapability from basilisk.enums is consistent with the PR's objective of centralizing enums in a dedicated module.

basilisk/provider_engine/deepseek_engine.py (2)

11-12: LGTM! Clean separation of model and enum imports.

The separation of model imports (Message, MessageBlock) from enum imports (MessageRole, ProviderCapability) improves code organization.


90-90: LGTM! Correct enum usage.

The update to use MessageRole.ASSISTANT aligns with the centralized enum approach.

basilisk/config/main_config.py (2)

7-8: LGTM! Clean import of centralized enums.

The import of enums from basilisk.enums aligns with the centralization objective.


23-27: LGTM! Consistent enum usage in field types.

The field types and default values are correctly updated to use the new centralized enums.

basilisk/conversation/conversation_helper.py (1)

13-15: LGTM! Clean separation of model and enum imports.

The separation of the ImageFile model import from the ImageFileTypes enum import improves code organization while maintaining functionality.

basilisk/enums.py (1)

1-4: LGTM! Good organization of imports.

The file has a clean structure with proper imports and type hints.

basilisk/provider.py (1)

9-9: LGTM! Clean enum migration.

The change correctly imports ProviderAPIType from the centralized enums module.

basilisk/main_app.py (1)

15-15: LGTM! Clean enum migration.

The changes correctly import and use AutomaticUpdateMode from the centralized enums module.

Also applies to: 76-77, 89-90, 95-96

basilisk/message_segment_manager.py (1)

7-7: LGTM! Clean enum migration.

The change correctly imports MessageSegmentType from the centralized enums module.

basilisk/provider_engine/gemini_engine.py (3)

9-10: LGTM! Clean import reorganization.

The imports have been properly reorganized to use the new enum module location.


101-109: LGTM! Consistent enum usage in role conversion.

The role conversion logic has been updated to use the new MessageRole enum while maintaining the same functionality.


164-164: LGTM! Consistent enum usage in response handling.

The response role assignment has been updated to use the new MessageRole enum.

basilisk/provider_engine/anthropic_engine.py (2)

12-13: LGTM! Clean import reorganization.

The imports have been properly reorganized to use the new enum module location.


207-207: LGTM! Consistent enum usage in response handling.

The response role assignment has been updated to use the new MessageRole enum.

basilisk/conversation/image_model.py (2)

25-25: LGTM! Clean import reorganization.

The import has been properly updated to use the new enum module location.


164-165: LGTM! Consistent enum usage in type property.

The type property correctly uses the imported ImageFileTypes enum.

basilisk/provider_engine/openai_engine.py (2)

20-21: LGTM! Clean import reorganization.

The imports have been properly reorganized to use the new enum module location.


324-324: LGTM! Consistent enum usage in response handling.

The response role assignment has been updated to use the new MessageRole enum.

basilisk/gui/search_dialog.py (1)

6-6: LGTM! Clean enum refactoring.

The change successfully moves the SearchDirection and SearchMode enums to the centralized basilisk.enums module while maintaining the existing functionality.

basilisk/gui/preferences_dialog.py (2)

7-7: LGTM! Clean enum imports.

The import statement correctly brings in the enums from the centralized basilisk.enums module.


13-17: LGTM! Improved enum label handling.

Using the get_labels() method from the enum classes is a cleaner approach than maintaining separate dictionaries for labels.

basilisk/config/account_config.py (3)

28-28: LGTM! Clean enum imports.

The import statement correctly brings in the enums from the centralized basilisk.enums module.


44-44: LGTM! Correct enum field type update.

The field type has been correctly updated to use the new KeyStorageMethod enum.


56-56: LGTM! Consistent enum usage in validation.

The validation logic correctly uses the new KeyStorageMethod enum while maintaining the same functionality.

Also applies to: 60-60

basilisk/updater.py (2)

17-18: LGTM! Clean enum imports.

The import statement correctly brings in the ReleaseChannel enum from the centralized basilisk.enums module.


426-431: LGTM! Clean enum usage in match statement.

The match-case statement correctly uses the new ReleaseChannel enum while maintaining the same control flow logic.

basilisk/gui/account_dialog.py (3)

8-9: LGTM!

The import statements have been updated to import enums from the dedicated basilisk.enums module, which aligns with the PR objectives.


16-18: LGTM!

The key storage methods dictionary correctly uses the new KeyStorageMethod enum values.


150-150: LGTM!

The code now uses AccountSource.get_labels() to retrieve labels, which is a more maintainable approach as it centralizes label management in the enum class.

Also applies to: 542-542

basilisk/gui/main_frame.py (1)

16-18: LGTM!

The import statements have been updated to import enums from the dedicated basilisk.enums module, which aligns with the PR objectives.

basilisk/gui/conversation_tab.py (5)

30-30: LGTM!

The import statements have been updated to import enums from the dedicated basilisk.enums module, which aligns with the PR objectives.


56-56: LGTM!

The code now uses MessageRole.get_labels() to retrieve labels, which is a more maintainable approach as it centralizes label management in the enum class.


1080-1080: LGTM!

The code correctly uses MessageRole.SYSTEM for system messages.


1096-1096: LGTM!

The code correctly uses MessageRole.USER for user messages.


1319-1319: LGTM!

The code correctly uses MessageRole.USER for title generation.

basilisk/server_thread.py (1)

11-11: LGTM!

The import statements have been updated to import enums from the dedicated basilisk.enums module, which aligns with the PR objectives.

basilisk/provider_engine/base_engine.py (1)

9-9: Updated Import for ProviderCapability
The import for ProviderCapability has been correctly updated to use the centralized enum from basilisk.enums, ensuring consistency in how provider capabilities are referenced throughout the codebase.

basilisk/provider_engine/mistralai_engine.py (1)

4-7: Refactored ProviderCapability Import
The changes in this file now import ProviderCapability directly from basilisk.enums instead of indirectly via the openai_engine module. This reduces coupling between modules and aligns with the new refactoring goal of centralizing enums.

tests/test_message_position_manager.py (1)

3-3: Updated Import for MessageSegmentType
The test file now imports MessageSegmentType from basilisk.enums, consistent with the reorganization of enum definitions. This update does not impact the test logic and positively contributes to maintainability.

Comment on lines 52 to 68
class ImageFileTypes(Enum):
UNKNOWN = "unknown"
IMAGE_LOCAL = "local"
IMAGE_MEMORY = "memory"
IMAGE_URL = "http"

@classmethod
def _missing_(cls, value: object) -> ImageFileTypes:
if isinstance(value, str) and value.lower() == "data":
return cls.IMAGE_URL
if isinstance(value, str) and value.lower() == "https":
return cls.IMAGE_URL
if isinstance(value, str) and value.lower() == "zip":
return cls.IMAGE_LOCAL
return cls.UNKNOWN

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider using a more robust pattern matching in _missing_.

The _missing_ method in ImageFileTypes could be improved for better maintainability and readability.

 @classmethod
 def _missing_(cls, value: object) -> ImageFileTypes:
-    if isinstance(value, str) and value.lower() == "data":
-        return cls.IMAGE_URL
-    if isinstance(value, str) and value.lower() == "https":
-        return cls.IMAGE_URL
-    if isinstance(value, str) and value.lower() == "zip":
-        return cls.IMAGE_LOCAL
+    if not isinstance(value, str):
+        return cls.UNKNOWN
+    
+    value_lower = value.lower()
+    url_schemes = {"data", "https"}
+    if value_lower in url_schemes:
+        return cls.IMAGE_URL
+    if value_lower == "zip":
+        return cls.IMAGE_LOCAL
     return cls.UNKNOWN
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class ImageFileTypes(Enum):
UNKNOWN = "unknown"
IMAGE_LOCAL = "local"
IMAGE_MEMORY = "memory"
IMAGE_URL = "http"
@classmethod
def _missing_(cls, value: object) -> ImageFileTypes:
if isinstance(value, str) and value.lower() == "data":
return cls.IMAGE_URL
if isinstance(value, str) and value.lower() == "https":
return cls.IMAGE_URL
if isinstance(value, str) and value.lower() == "zip":
return cls.IMAGE_LOCAL
return cls.UNKNOWN
class ImageFileTypes(Enum):
UNKNOWN = "unknown"
IMAGE_LOCAL = "local"
IMAGE_MEMORY = "memory"
IMAGE_URL = "http"
@classmethod
def _missing_(cls, value: object) -> ImageFileTypes:
if not isinstance(value, str):
return cls.UNKNOWN
value_lower = value.lower()
url_schemes = {"data", "https"}
if value_lower in url_schemes:
return cls.IMAGE_URL
if value_lower == "zip":
return cls.IMAGE_LOCAL
return cls.UNKNOWN

basilisk/enums.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec248e and aabdcca.

📒 Files selected for processing (3)
  • basilisk/config/account_config.py (8 hunks)
  • basilisk/enums.py (1 hunks)
  • basilisk/gui/account_dialog.py (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_app / build_windows (x86)
  • GitHub Check: build_app / build_windows (x64)
🔇 Additional comments (13)
basilisk/enums.py (11)

6-18: LGTM!

The AccountSource enum is well-implemented with proper string values and translation support.


20-38: LGTM!

The AutomaticUpdateMode enum is well-implemented with proper string values and translation support.


40-44: LGTM!

The CaptureMode enum is well-implemented with proper string values.


52-68: Consider using a more robust pattern matching in _missing_.

The _missing_ method in ImageFileTypes could be improved for better maintainability and readability.


70-73: LGTM!

The KeyStorageMethod enum is well-implemented with proper string values.


75-99: Consider using an IntEnum for LogLevel.

Since LogLevel represents standard logging levels that map to integers in Python's logging module, consider using IntEnum for better interoperability.


116-120: LGTM!

The MessageSegmentType enum is well-implemented with proper string values.


122-127: LGTM!

The ProviderAPIType enum is well-implemented with proper string values.


129-134: LGTM!

The ProviderCapability enum is well-implemented with proper string values.


136-151: LGTM!

The ReleaseChannel enum is well-implemented with proper string values and translation support.


153-162: LGTM!

Both SearchDirection and SearchMode enums are well-implemented with proper integer values.

basilisk/config/account_config.py (1)

28-28: LGTM!

The changes to replace KeyStorageMethodEnum with KeyStorageMethod are consistent and maintain the same functionality.

Also applies to: 44-44, 56-56, 60-60, 70-70, 72-72, 79-79, 98-99, 128-128, 132-132, 142-142, 144-144, 221-221

basilisk/gui/account_dialog.py (1)

8-9: LGTM!

The changes to replace KeyStorageMethodEnum with KeyStorageMethod and update label retrieval are consistent and maintain the same functionality.

Also applies to: 16-16, 18-18, 150-150, 542-542

basilisk/enums.py Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
basilisk/enums.py (2)

75-99: 🧹 Nitpick (assertive)

Consider using IntEnum for LogLevel.

Since LogLevel represents standard logging levels that map to integers in Python's logging module, consider using IntEnum for better interoperability.

-class LogLevel(StrEnum):
+class LogLevel(IntEnum):
-    NOTSET = "off"
-    DEBUG = auto()
-    INFO = auto()
-    WARNING = auto()
-    ERROR = auto()
-    CRITICAL = auto()
+    NOTSET = 0
+    DEBUG = 10
+    INFO = 20
+    WARNING = 30
+    ERROR = 40
+    CRITICAL = 50

101-114: 🧹 Nitpick (assertive)

Add missing label for SYSTEM role.

The get_labels method doesn't include a label for the SYSTEM role. Consider adding it for completeness.

 @classmethod
 def get_labels(cls) -> dict[MessageRole, str]:
     return {
         # Translators: Label indicating that the message is from the user in a conversation
         cls.USER: _("User:") + ' ',
         # Translators: Label indicating that the message is from the assistant in a conversation
         cls.ASSISTANT: _("Assistant:") + ' ',
+        # Translators: Label indicating that the message is from the system in a conversation
+        cls.SYSTEM: _("System:") + ' ',
     }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aabdcca and 4ddd0df.

📒 Files selected for processing (31)
  • basilisk/config/__init__.py (0 hunks)
  • basilisk/config/account_config.py (8 hunks)
  • basilisk/config/config_enums.py (0 hunks)
  • basilisk/config/main_config.py (2 hunks)
  • basilisk/consts.py (0 hunks)
  • basilisk/conversation/__init__.py (1 hunks)
  • basilisk/conversation/conversation_helper.py (1 hunks)
  • basilisk/conversation/conversation_model.py (1 hunks)
  • basilisk/conversation/image_model.py (1 hunks)
  • basilisk/enums.py (1 hunks)
  • basilisk/gui/account_dialog.py (3 hunks)
  • basilisk/gui/conversation_tab.py (6 hunks)
  • basilisk/gui/main_frame.py (1 hunks)
  • basilisk/gui/preferences_dialog.py (3 hunks)
  • basilisk/gui/search_dialog.py (1 hunks)
  • basilisk/main_app.py (3 hunks)
  • basilisk/message_segment_manager.py (1 hunks)
  • basilisk/provider.py (1 hunks)
  • basilisk/provider_capability.py (0 hunks)
  • basilisk/provider_engine/anthropic_engine.py (2 hunks)
  • basilisk/provider_engine/base_engine.py (1 hunks)
  • basilisk/provider_engine/deepseek_engine.py (2 hunks)
  • basilisk/provider_engine/gemini_engine.py (3 hunks)
  • basilisk/provider_engine/mistralai_engine.py (1 hunks)
  • basilisk/provider_engine/openai_engine.py (2 hunks)
  • basilisk/provider_engine/openrouter_engine.py (1 hunks)
  • basilisk/provider_engine/xai_engine.py (1 hunks)
  • basilisk/screen_capture_thread.py (1 hunks)
  • basilisk/server_thread.py (1 hunks)
  • basilisk/updater.py (2 hunks)
  • tests/test_message_position_manager.py (1 hunks)
💤 Files with no reviewable changes (4)
  • basilisk/consts.py
  • basilisk/config/init.py
  • basilisk/provider_capability.py
  • basilisk/config/config_enums.py
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build_app / build_windows (x86)
  • GitHub Check: build_app / build_windows (x64)
🔇 Additional comments (52)
basilisk/gui/preferences_dialog.py (12)

7-7: Switching to enums module import.
The import from basilisk.enums aligns perfectly with the new dedicated module approach.


13-13: Populating log_levels from LogLevel.get_labels().
Looks good and follows the new enum usage pattern.


15-15: Populating release_channels from ReleaseChannel.get_labels().
No issues detected.


17-17: Populating auto_update_modes from AutomaticUpdateMode.get_labels().
Implementation is consistent with the refactoring.


41-41: Possible KeyError on invalid config key.
self.conf.general.log_level must match a valid log_levels key. Consider gracefully handling unknown enum keys if the config is corrupted or outdated.


44-44: No concerns with combobox choices.
These choices cleanly map log_levels.values() for display.


83-83: Possible KeyError on invalid config key.
self.conf.general.release_channel must correspond to a valid release_channels key. Consider a safe fallback.


88-88: Combobox choices for release channels look correct.
Proper usage of release_channels.values().


98-101: Handled enum-based combo initialization.
However, if self.conf.general.automatic_update_mode is invalid, it may cause a KeyError.


311-311: Validate GetSelection() index.
Ensure list(log_levels.keys())[self.log_level.GetSelection()] remains within bounds.


318-318: Validate GetSelection() index for release channel.
Same principle; out-of-range selection could raise an IndexError.


321-321: Validate GetSelection() index for automatic update mode.
Similarly, handle potential out-of-range errors.

basilisk/conversation/__init__.py (1)

2-2: Removing MessageRoleEnum import.
This is consistent with the move to the new enums module.

basilisk/provider_engine/xai_engine.py (1)

4-7: Switching ProviderCapability import source.
Importing from basilisk.enums is aligned with the dedicated enums refactor.

basilisk/conversation/conversation_model.py (1)

8-8: LGTM! The enum refactoring looks good.

The changes correctly implement the PR objective by:

  1. Importing MessageRole from the new dedicated enums module
  2. Updating the type annotation in the Message class

Also applies to: 16-16

basilisk/server_thread.py (1)

11-11: LGTM! The enum import update is correct.

The import statement has been properly updated to use the new dedicated enums module.

basilisk/provider_engine/deepseek_engine.py (1)

11-12: LGTM! The enum refactoring is consistent.

The changes correctly:

  1. Import enums from the dedicated module
  2. Update the message role usage in the response creation

Also applies to: 90-90

basilisk/config/main_config.py (1)

7-8: LGTM! The enum refactoring is thorough.

The changes correctly:

  1. Import multiple enums from the dedicated module
  2. Update all relevant type annotations in the GeneralSettings class

Also applies to: 23-27

basilisk/enums.py (4)

6-18: LGTM!

The enum implementation is clean and follows best practices. The get_labels method provides proper translations for UI display.


20-38: LGTM!

The enum implementation is clean and follows best practices. The get_labels method provides proper translations for UI display.


52-68: LGTM!

The enum implementation is clean and follows best practices. The _missing_ method has been improved for better maintainability.


116-162: LGTM!

The remaining enum implementations are clean and follow best practices.

basilisk/main_app.py (1)

15-15: LGTM!

The changes correctly update the imports and enum references as part of the enum refactoring.

Also applies to: 76-76, 89-89, 95-95

basilisk/provider_engine/gemini_engine.py (1)

9-10: LGTM!

The changes correctly update the imports and enum references as part of the enum refactoring.

Also applies to: 101-107, 164-164

basilisk/provider_engine/anthropic_engine.py (1)

12-13: LGTM!

The changes correctly update the imports and enum references as part of the enum refactoring.

Also applies to: 207-207

basilisk/conversation/image_model.py (2)

25-25: LGTM! Import updated correctly.

The import statement has been updated to use the new centralized enum module.


164-165: Verify the type property implementation.

The property now relies on the protocol attribute of the location to determine the image type. This change could potentially introduce issues if the protocol values don't match the expected ImageFileTypes enum values.

basilisk/provider_engine/openai_engine.py (2)

20-21: LGTM! Imports updated correctly.

The imports have been updated to use the new centralized enum module while maintaining the necessary imports from conversation module.


324-324: LGTM! Enum usage updated correctly.

The MessageRole.ASSISTANT usage is consistent with the new enum structure.

basilisk/config/account_config.py (2)

28-28: LGTM! Imports updated correctly.

The imports have been updated to use the new centralized enum module.


44-44: LGTM! Enum usage updated consistently.

All references to KeyStorageMethodEnum have been correctly updated to use KeyStorageMethod. The validation logic and storage method checks remain functionally equivalent.

Also applies to: 56-56, 60-60, 70-70, 72-72, 79-79, 98-99, 128-128, 132-132, 142-142, 144-144, 221-221

basilisk/updater.py (2)

17-18: LGTM! Imports updated correctly.

The imports have been updated to use the new centralized enum module.


426-431: LGTM! Match cases updated correctly.

The match cases have been updated to use ReleaseChannel consistently:

  • STABLE case for stable releases
  • BETA case for pre-releases
  • DEV case for nightly builds
basilisk/gui/account_dialog.py (3)

8-9: LGTM: Import statements updated correctly.

The imports have been properly updated to use the new enum module.


15-18: LGTM: Key storage method enum usage updated correctly.

The key_storage_methods dictionary correctly uses the new KeyStorageMethod enum.


150-150: LGTM: Account source labels retrieval updated correctly.

The code now uses AccountSource.get_labels() method consistently.

Also applies to: 542-542

basilisk/gui/main_frame.py (3)

16-18: LGTM: Import statements updated correctly.

The imports have been properly updated to use the new enum module.


232-246: LGTM: Hotkey registration updated correctly.

The hotkey registration code correctly uses the new HotkeyAction enum.


248-256: LGTM: Hotkey handling updated correctly.

The hotkey handling code correctly uses the new HotkeyAction enum with pattern matching.

basilisk/gui/conversation_tab.py (3)

30-30: LGTM: Import statements updated correctly.

The imports have been properly updated to use the new enum module.


56-56: LGTM: Role labels retrieval updated correctly.

The code now uses MessageRole.get_labels() method for role labels.


1080-1080: LGTM: Message role assignments updated correctly.

The code consistently uses the new MessageRole enum for all message role assignments.

Also applies to: 1096-1096, 1160-1160, 1319-1319

basilisk/screen_capture_thread.py (1)

11-11: LGTM: Import statement updated correctly.

The import has been properly updated to use the new enum module.

basilisk/provider_engine/openrouter_engine.py (1)

9-9: Centralized ProviderCapability Import
The import for ProviderCapability has been updated to use the centralized enum from basilisk.enums instead of the legacy source. This change is consistent with the project’s objective to consolidate enums into a dedicated module.

basilisk/provider_engine/base_engine.py (1)

9-9: Unified ProviderCapability Source
The import of ProviderCapability is now sourced from basilisk.enums, which improves consistency across the codebase and aligns with the refactoring objective. No further modifications are needed here.

basilisk/provider_engine/mistralai_engine.py (1)

4-4: Updated Enum Import in MistralAIEngine
ProviderCapability is now imported from basilisk.enums rather than an old location. This update ensures that the enum source is uniform across all engine modules and simplifies dependency management.

basilisk/conversation/conversation_helper.py (1)

13-15: Refactored ImageFileTypes Import
The import for ImageFileTypes has been updated to reference the centralized enum in basilisk.enums. This change, along with removing it from the local import of .image_model, guarantees that all references to image file types are maintained from a single source.

basilisk/provider.py (1)

9-9: Migrated ProviderAPIType to Centralized Module
The local definition of ProviderAPIType has been replaced with an import from basilisk.enums. This refactoring drives consistency in enum usage across the application without altering provider functionality.

basilisk/message_segment_manager.py (2)

7-7: Migrate Enum Import Successfully.
The import on line 7 now sources MessageSegmentType from the centralized basilisk.enums module instead of defining it locally. Please confirm that the centralized enum includes all the expected members (e.g., PREFIX, CONTENT, SUFFIX) so that its usage throughout the module remains consistent.


135-139: Verify Enum Member Semantics in Focus Method.
Within the focus_content_block method (lines 135–139), the code compares the current segment’s kind against MessageSegmentType.PREFIX and MessageSegmentType.SUFFIX and then navigates accordingly. Ensure that these enum members in the centralized module retain the same semantics as those previously defined locally.

tests/test_message_position_manager.py (1)

3-3: Updated Enum Import for Test Consistency.
The change on line 3 imports MessageSegmentType from basilisk.enums instead of from the local module. This aligns tests with the refactored organization. Please verify that all enum member references in tests (e.g., CONTENT, PREFIX) remain valid in the new centralized definition.

basilisk/gui/search_dialog.py (1)

6-6: Centralize GUI Enum Usage.
On line 6, SearchDirection and SearchMode are now imported from basilisk.enums, which is a welcome improvement for consistency and maintainability across the codebase. Please ensure that the definitions in the centralized module provide all the necessary members for the search dialog’s logic.

Comment on lines +46 to +50
class HotkeyAction(IntEnum):
TOGGLE_VISIBILITY = 1
CAPTURE_FULL = 20
CAPTURE_WINDOW = 21

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Document the value gaps in HotkeyAction.

The enum values are not sequential (1, 20, 21). Consider adding a comment explaining why these specific values were chosen and what the gaps represent.

@clementb49 clementb49 closed this Feb 8, 2025
@clementb49 clementb49 deleted the enumModule branch February 8, 2025 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant