{"record":{"id":"13e3417eff45a1cb","repo":"matplotlib/matplotlib","slug":"cycler-must-have-positional-or-keyword-arguments","errorCode":null,"errorMessage":"cycler() must have positional OR keyword arguments","messagePattern":"cycler\\(\\) must have positional OR keyword arguments","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/rcsetup.py","lineNumber":790,"sourceCode":"\n    Examples\n    --------\n    Creating a cycler for a single property:\n\n    >>> c = cycler(color=['red', 'green', 'blue'])\n\n    Creating a cycler for simultaneously cycling over multiple properties\n    (e.g. red circle, green plus, blue cross):\n\n    >>> c = cycler(color=['red', 'green', 'blue'],\n    ...            marker=['o', '+', 'x'])\n\n    \"\"\"\n    if args and kwargs:\n        raise TypeError(\"cycler() can only accept positional OR keyword \"\n                        \"arguments -- not both.\")\n    elif not args and not kwargs:\n        raise TypeError(\"cycler() must have positional OR keyword arguments\")\n\n    if len(args) == 1:\n        if not isinstance(args[0], Cycler):\n            raise TypeError(\"If only one positional argument given, it must \"\n                            \"be a Cycler instance.\")\n        return validate_cycler(args[0])\n    elif len(args) == 2:\n        pairs = [(args[0], args[1])]\n    elif len(args) > 2:\n        raise _api.nargs_error('cycler', '0-2', len(args))\n    else:\n        pairs = kwargs.items()\n\n    validated = []\n    for prop, vals in pairs:\n        norm_prop = _prop_aliases.get(prop, prop)\n        validator = _prop_validators.get(norm_prop, None)\n        if validator is None:","sourceCodeStart":772,"sourceCodeEnd":808,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/rcsetup.py#L772-L808","documentation":"matplotlib.rcsetup.cycler() (lib/matplotlib/rcsetup.py:790) raises TypeError when called with neither positional nor keyword arguments. A cycler must cycle over at least one artist property, so an empty call is rejected before any validation happens.","triggerScenarios":"cycler(); cycler(*[], **{}); dynamically built argument dicts that turn out empty, e.g. cycler(**cycle_dict) where cycle_dict == {}.","commonSituations":"Building prop_cycle kwargs programmatically from a config dict or user input that is empty; refactoring leaves a placeholder cycler() call; a helper function that forwards **kwargs which contain nothing.","solutions":["Pass at least one property, e.g. cycler(color=['r','g','b'])","Guard dynamic construction: only build a cycler when the dict is non-empty, otherwise keep the default rcParams['axes.prop_cycle']","Log or assert on empty config before calling cycler(**cfg)"],"exampleFix":"# before\nmpl.rcParams['axes.prop_cycle'] = cycler(**user_cycle_cfg)  # user_cycle_cfg == {}\n# after\nif user_cycle_cfg:\n    mpl.rcParams['axes.prop_cycle'] = cycler(**user_cycle_cfg)","handlingStrategy":"validation","validationCode":"mpl.rcParams['axes.prop_cycle'] = cycler(**cfg) if cfg else mpl.rcParams['axes.prop_cycle']","typeGuard":"def has_cycle_properties(cfg):\n    return len(cfg) > 0","tryCatchPattern":"try:\n    cyc = cycler(**cfg)\nexcept TypeError as e:\n    if 'must have positional OR keyword' in str(e):\n        cyc = cycler(color=['tab:blue'])  # sane default\n    else:\n        raise","preventionTips":["Guard dynamic **kwargs dicts for emptiness before calling cycler","Log when a config produces an empty prop_cycle","Provide a default palette in your config loader"],"tags":["matplotlib","cycler","rcsetup","typeerror","prop-cycle"],"backgroundTag":"invalid-function-arguments","analyzedSha":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}