Skip to content

refactor: add ModeType enum for client/server mode selection#2112

Open
Ayush10 wants to merge 1 commit intomicrosoft:mainfrom
Ayush10:refactor/issue-813-add-mode-type-enum
Open

refactor: add ModeType enum for client/server mode selection#2112
Ayush10 wants to merge 1 commit intomicrosoft:mainfrom
Ayush10:refactor/issue-813-add-mode-type-enum

Conversation

@Ayush10
Copy link

@Ayush10 Ayush10 commented Jan 30, 2026

Summary

  • Introduces a ModeType(str, Enum) in qlib/constant.py with CLIENT and SERVER values
  • Updates MODE_CONF dictionary keys to use ModeType enum instead of raw strings
  • Updates set_mode() to convert string arguments to ModeType via ModeType(mode)
  • Updates set() method signature to accept Union[str, ModeType]
  • Full backward compatibility: ModeType.CLIENT == "client" is True since ModeType inherits from str

Test plan

  • Verified ModeType.CLIENT == "client" and ModeType.SERVER == "server" evaluate to True
  • Verified MODE_CONF[ModeType("client")] works (string-to-enum conversion)
  • Verified MODE_CONF[ModeType.CLIENT] works (direct enum access)
  • Existing tests pass without modification (no consumer code changes needed)

Closes #813

Introduces a ModeType(str, Enum) in qlib/constant.py with CLIENT and
SERVER values. Updates MODE_CONF keys and set_mode() to use the enum
while maintaining full backward compatibility with string arguments.

Closes microsoft#813
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.

[Refactor] Add enum ModeType for client/server selection.

1 participant