ManimCommunity / ManimCommunity/manim

config: return ManimColor instance from background_color property

Open
#4,801 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## 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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in manim/_config/utils.py at line 1193 and trace the import relationship to the ManimColor definition. Compare the getter's annotation with the stored value and inspect related color-typed config properties. Done means background_color returns a ManimColor instance without introducing a circular import, with coverage for the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.