{"record":{"id":"1b8a90f8ba80f280","repo":"3b1b/manim","slug":"invalid-argument-to-group-of-type-type-args-0","errorCode":null,"errorMessage":"Invalid argument to Group of type {type(args[0])}","messagePattern":"Invalid argument to Group of type (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"manimlib/mobject/mobject.py","lineNumber":2100,"sourceCode":"                      \"for a Mobject with no points\"\n            caller_name = sys._getframe(1).f_code.co_name\n            raise Exception(message.format(caller_name))\n\n\nclass Group(Mobject, Generic[SubmobjectType]):\n    def __init__(self, *mobjects: SubmobjectType | Iterable[SubmobjectType], **kwargs):\n        super().__init__(**kwargs)\n        self._ingest_args(*mobjects)\n\n    def _ingest_args(self, *args: Mobject | Iterable[Mobject]):\n        if len(args) == 0:\n            return\n        if all(isinstance(mob, Mobject) for mob in args):\n            self.add(*args)\n        elif isinstance(args[0], Iterable):\n            self.add(*args[0])\n        else:\n            raise Exception(f\"Invalid argument to Group of type {type(args[0])}\")\n\n    def __add__(self, other: Mobject | Group) -> Self:\n        assert isinstance(other, Mobject)\n        return self.add(other)\n\n    # This is just here to make linters happy with references to things like Group(...)[0]\n    def __getitem__(self, index) -> SubmobjectType:\n        return super().__getitem__(index)\n\n\nclass Point(Mobject):\n    def __init__(\n        self,\n        location: Vect3 = ORIGIN,\n        artificial_width: float = 1e-6,\n        artificial_height: float = 1e-6,\n        **kwargs\n    ):","sourceCodeStart":2082,"sourceCodeEnd":2118,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/mobject/mobject.py#L2082-L2118","documentation":"Formatted Exception from Group._ingest_args (manimlib/mobject/mobject.py:2100): 'Invalid argument to Group of type {type(args[0])}'. Group accepts either several Mobject instances or a single iterable of Mobjects; anything else — an int, a string, a dict, None — falls to the else branch. (Note: a str IS iterable, so Group(\"ab\") would instead try add('a','b') and fail differently; the raise fires for non-iterable, non-Mobject first args.)","triggerScenarios":"Group(5), Group(None), Group(True); passing a numpy array of mobjects is accepted (iterable), but passing an unwrapped scalar or an object that is neither Mobject nor Iterable raises; mixed args like Group(mob, [mob2]) fall into the else because not all are Mobjects and args[0] is a Mobject... in that case args[0] IS a Mobject but not Iterable — actually isinstance(Mobject, Iterable) is False, so Group(mob, [mob2]) also raises with type of args[0].","commonSituations":"Passing a count or index by mistake (Group(len(items))); passing keyword-style scalars; mixing a single mobject with a list in the same call; API refactor changing a function to return a scalar that gets forwarded to Group.","solutions":["Flatten arguments before constructing: Group(*all_mobjects) where every element is a Mobject","Wrap scalars/optionals: Group(m) if m is not None else Group(); never pass ints/None/bools","Do not mix one Mobject with a list — Group(m, *others) or Group(m, VGroup(*others))"],"exampleFix":"# before\ng = Group(count)              # count is an int -> raises\ng = Group(mob, [mob2, mob3])  # mixed -> raises (args[0] is Mobject, not iterable-of-check)\n\n# after\ng = Group(mob, mob2, mob3)    # all Mobjects\n# or\ng = Group(mob, *[mob2, mob3])","handlingStrategy":"type-guard","validationCode":"from collections.abc import Iterable\nfrom manimlib.mobject.mobject import Mobject\n\ndef build_group(*args):\n    mobs = []\n    for a in args:\n        if isinstance(a, Mobject):\n            mobs.append(a)\n        elif isinstance(a, Iterable) and not isinstance(a, str):\n            mobs.extend(a)\n        else:\n            raise TypeError(f\"cannot add {a!r} of type {type(a).__name__} to a Group\")\n    return Group(*mobs)","typeGuard":"def is_group_arg(obj) -> bool:\n    return isinstance(obj, Mobject) or (isinstance(obj, Iterable) and not isinstance(obj, str))","tryCatchPattern":null,"preventionTips":["Flatten mixed Mobject/list arguments before Group(...)","Never pass scalars, None, bools, or strings to Group","Type-hint helper functions that feed Group as Sequence[Mobject]"],"tags":["manim","group","validation","type-checking"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}