Skip to content

Make the Settings class hashable #374

Open
@WonderPG

Description

@WonderPG

Currently some settings sub-classes are not frozen, and some arguments are dictionaries which are not hashable. For instance

class MCPServerConfig(BaseModel):
    """Configuration for a single MCP server."""

    command: str
    args: list[str] | None = None
    env: dict[str, SecretStr] | None = None


class SettingsMCP(BaseModel):
    """Settings for the MCP."""

    servers: dict[str, MCPServerConfig] | None = None

One should find a way to make these classes hashable. For instance @jankrepl 's idea is to do something like this:

class MCPEnv(BaseModel):
    model_config = ConfigDict(frozen=True, extra="allow")

class MCPServerConfig(BaseModel):
    """Configuration for a single MCP server."""

    command: str
    args: tuple[str] | None = None
    env: MCPEnv | None = None

    model_config = ConfigDict(frozen=True)

There might be other ways to do it. To be investigated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions