{"record":{"id":"c52af0a4cc9b2a70","repo":"pypa/pip","slug":"filter-filtername-r-not-found","errorCode":null,"errorMessage":"filter {filtername!r} not found","messagePattern":"filter (.+?) not found","errorType":"exception","errorClass":"ClassNotFound","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/pygments/filters/__init__.py","lineNumber":42,"sourceCode":"    if filtername in FILTERS:\n        return FILTERS[filtername]\n    for name, cls in find_plugin_filters():\n        if name == filtername:\n            return cls\n    return None\n\n\ndef get_filter_by_name(filtername, **options):\n    \"\"\"Return an instantiated filter.\n\n    Options are passed to the filter initializer if wanted.\n    Raise a ClassNotFound if not found.\n    \"\"\"\n    cls = find_filter_class(filtername)\n    if cls:\n        return cls(**options)\n    else:\n        raise ClassNotFound(f'filter {filtername!r} not found')\n\n\ndef get_all_filters():\n    \"\"\"Return a generator of all filter names.\"\"\"\n    yield from FILTERS\n    for name, _ in find_plugin_filters():\n        yield name\n\n\ndef _replace_special(ttype, value, regex, specialttype,\n                     replacefunc=lambda x: x):\n    last = 0\n    for match in regex.finditer(value):\n        start, end = match.start(), match.end()\n        if start != last:\n            yield ttype, value[last:start]\n        yield specialttype, replacefunc(value[start:end])\n        last = end","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_vendor/pygments/filters/__init__.py#L24-L60","documentation":"Raised by get_filter_by_name when the requested filter name is neither in the built-in FILTERS dict nor found among registered plugin filters. Returns ClassNotFound, the standard pygments exception for missing lookups. Callers must pass a recognized filter name.","triggerScenarios":"Calling get_filter_by_name('nonexistent') or a misspelled name; calling it before plugin entry points are installed; requesting a filter that exists only in a newer pygments version.","commonSituations":"Typo in a filter name in config; using a filter name from documentation for a different pygments version; referencing a third-party filter whose plugin isn't installed.","solutions":["Check get_all_filters() for the exact set of available names and use one of those.","Install the plugin package that registers the missing filter.","Upgrade pygments if the filter was added in a newer release.","Correct typos (names are case-sensitive and lowercase, e.g. 'tokenreplace')."],"exampleFix":"# before\nf = get_filter_by_name('RaiseOnError')\n# after\nf = get_filter_by_name('raiseonerror')","handlingStrategy":"try-catch","validationCode":"from pip._vendor.pygments.filters import find_filter_class\nif find_filter_class(name) is None:\n    raise ValueError(f'unknown filter: {name}')","typeGuard":"def filter_exists(name: str) -> bool:\n    from pip._vendor.pygments.filters import find_filter_class\n    return find_filter_class(name) is not None","tryCatchPattern":"from pip._vendor.pygments.util import ClassNotFound\ntry:\n    f = get_filter_by_name(name)\nexcept ClassNotFound:\n    f = None  # or a default filter","preventionTips":["Validate names via find_filter_class before calling get_filter_by_name.","Cross-check against get_all_filters() output."],"tags":["python","pygments","filter","validation","vendored"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}