{"record":{"id":"e26d82816c8c1a56","repo":"matplotlib/matplotlib","slug":"markevery-list-must-have-all-elements-of-type-in","errorCode":null,"errorMessage":"'markevery' list must have all elements of type int","messagePattern":"'markevery' list must have all elements of type int","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/rcsetup.py","lineNumber":603,"sourceCode":"    \"\"\"\n    # Validate s against type slice float int and None\n    if isinstance(s, (slice, float, int, type(None))):\n        return s\n    # Validate s against type tuple\n    if isinstance(s, tuple):\n        if (len(s) == 2\n                and (all(isinstance(e, int) for e in s)\n                     or all(isinstance(e, float) for e in s))):\n            return s\n        else:\n            raise TypeError(\n                \"'markevery' tuple must be pair of ints or of floats\")\n    # Validate s against type list\n    if isinstance(s, list):\n        if all(isinstance(e, int) for e in s):\n            return s\n        else:\n            raise TypeError(\n                \"'markevery' list must have all elements of type int\")\n    raise TypeError(\"'markevery' is of an invalid type\")\n\n\nvalidate_markeverylist = _listify_validator(validate_markevery)\n\n\ndef validate_bbox(s):\n    if isinstance(s, str):\n        s = s.lower()\n        if s == 'tight':\n            return s\n        if s == 'standard':\n            return None\n        raise ValueError(\"bbox should be 'tight' or 'standard'\")\n    elif s is not None:\n        # Backwards compatibility. None is equivalent to 'standard'.\n        raise ValueError(\"bbox should be 'tight' or 'standard'\")","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/rcsetup.py#L585-L621","documentation":"validate_markevery() rejects a list markevery whose elements are not all ints. A list form of markevery means 'draw markers exactly at these point indices', so only integers are meaningful; floats, strings, or None inside the list raise this TypeError. This runs when the 'markevery' key of axes.prop_cycle is validated.","triggerScenarios":"cycler(markevery=[[0, 1.5, 3]]) or [[0, '2', 3]] inside a prop_cycle; likewise a bad 'markevery:' line in a style file parsed to a list. Floats that happen to be whole numbers still fail - the check is isinstance-based, not value-based.","commonSituations":"Loading marker indices from JSON/YAML where the parser produced floats (e.g. 2.0) or numeric strings; reusing an index array from numpy without casting (a numpy int array is not a list of Python ints and fails the earlier list check with the generic type error instead).","solutions":["Coerce elements to int before use: [int(i) for i in idx_list]","If you meant a range, prefer the tuple form (start, step) instead of enumerating every index","Cast numpy arrays: arr.astype(int).tolist()"],"exampleFix":"# before\nfrom cycler import cycler\nimport matplotlib.pyplot as plt\nplt.rc('axes', prop_cycle=cycler(markevery=[[0, 2.0, 4]]))  # 2.0 is float\n\n# after\nplt.rc('axes', prop_cycle=cycler(markevery=[[0, 2, 4]]))","handlingStrategy":"type-guard","validationCode":"def valid_markevery_list(s):\n    return isinstance(s, list) and all(type(e) is int for e in s)\n\nassert valid_markevery_list([0, 2, 4])\nassert not valid_markevery_list([0, 2.0, 4])  # 2.0 is float, fails","typeGuard":"def is_markevery_index_list(v) -> bool:\n    return (isinstance(v, list) and len(v) > 0\n            and all(isinstance(e, int) and not isinstance(e, bool) for e in v))","tryCatchPattern":"try:\n    plt.rc('axes', prop_cycle=cycler(markevery=[idx_list]))\nexcept TypeError:\n    idx_list = [int(i) for i in idx_list]\n    plt.rc('axes', prop_cycle=cycler(markevery=[idx_list]))","preventionTips":["Cast JSON/YAML-derived indices with int() - parsers often produce floats for whole numbers","Convert numpy index arrays with .astype(int).tolist()","The check is type-based: 2.0 fails even though it equals 2"],"tags":["matplotlib","markevery","prop-cycle","rcparams"],"backgroundTag":"invalid-markevery","analyzedSha":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}