Skip to content

Use Field(default_factory=...) for mutable defaults in Lemma model #8

@mzargham

Description

@mzargham

Summary

The Lemma model in symproof/models.py uses bare mutable defaults for two fields:

  • Line 385: assumptions: dict[str, dict] = {}
  • Line 418: depends_on: list[str] = []

Impact

The model has frozen=True and Pydantic v2 internally copies defaults, so this is not a runtime bug. However, it violates Python best practice, will trigger linting warnings, and could confuse contributors.

Fix

from pydantic import Field

assumptions: dict[str, dict] = Field(default_factory=dict)
depends_on: list[str] = Field(default_factory=list)

Files

  • symproof/models.py:385,418

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions