Skip to content

config: return ManimColor instance from background_color property #4801

Description

@Drunsdo

Source

manim/_config/utils.py, line 1193 (as of HEAD ):

# TODO: This was parsed before maybe add ManimColor(val), but results in circular import
    @property
    def background_color(self) -> ManimColor:
        """Background color of the scene (-c)."""
        return self._d["background_color"]

Problem

The background_color property is type-annotated as ManimColor, but the underlying value stored in self._d is not wrapped in a ManimColor instance. The natural fix, return ManimColor(self._d["background_color"]), is blocked by a circular import between _config/utils.py and the ManimColor definition.

The mismatch between the annotation and the runtime value can mislead callers that rely on ManimColor methods being available on the returned object.

Suggested approaches

  • Lazy import of ManimColor inside the getter.
  • Restructure the import graph so _config/utils.py can import ManimColor at module level.
  • Audit other config properties that may have the same gap (e.g. other color-typed config values).

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