Skip to content

Conversation

@DiamondJoseph
Copy link
Contributor

Dummy commit to test out possible new pattern of how to create commands.
This form ensures that Settings object has been fully resolved before any commands are run, meaning that the Settings object can be treated as effectively immutable.

This pattern can be recursed down, with e.g.

class Settings(BaseSettings):
    command: CliSubCommand[Union[Client, Server]]

    def cli_cmd(self):
        CliApp.run_subcommand(self)

class Client(BaseModel):
    subcommand: CliSubCommand[Union[InMemory, FromUri]]

    def cli_cmd(self):
        CliApp.run_subcommand(self)

class InMemory(BaseModel):

    def cli_cmd(self):
        ...

Checklist

  • Add a Changelog entry
  • Add the ticket number which this PR closes to the comment section

Base automatically changed from settings-creation to main March 26, 2025 15:21
@DiamondJoseph
Copy link
Contributor Author

Deprecated and replaced by #930, a much more complete example.

@DiamondJoseph DiamondJoseph deleted the settings-entrypoint branch March 27, 2025 16:33
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.

2 participants