Skip to content

MLR117: register_font() context manager is called without with

qual reports MLR117 when a call resolving to manim.mobject.text.text_mobject.register_font is a bare expression statement — not the context expression of a with, not assigned, and not passed to another call.

  • Default severity: error
  • Minimum confidence: high
  • Implementation phase: 1
  • Fix: unsafe suggestion wrapping the call in with ...:

register_font is a @contextmanager generator function: calling it only creates the context object. The font is registered on __enter__ and unregistered on __exit__, so a bare call has no effect and the font is never available to Text. The suggested rewrite is UNSAFE because the statements that use the font must be moved into the block by hand.

Wrong:

register_font("fonts/custom.ttf")   # registers nothing
title = Text("hello", font="Custom Font")

Right:

with register_font("fonts/custom.ttf"):
    title = Text("hello", font="Custom Font")