{"record":{"id":"0c1872f50ce6e64a","repo":"astral-sh/ruff","slug":"unrecognized-language-s-expected-one-of-pyt","errorCode":null,"errorMessage":"Unrecognized language: `{s}`. Expected one of `python`, `pyi`, or `ipynb`.","messagePattern":"Unrecognized language: `(.+?)`\\. Expected one of `python`, `pyi`, or `ipynb`\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_linter/src/settings/types.rs","lineNumber":445,"sourceCode":"pub enum Language {\n    #[default]\n    Python,\n    Pyi,\n    Ipynb,\n    Markdown,\n}\n\nimpl FromStr for Language {\n    type Err = anyhow::Error;\n\n    fn from_str(s: &str) -> Result<Self, Self::Err> {\n        match s.to_ascii_lowercase().as_str() {\n            \"python\" => Ok(Self::Python),\n            \"pyi\" => Ok(Self::Pyi),\n            \"ipynb\" => Ok(Self::Ipynb),\n            \"md\" => Ok(Self::Markdown),\n            _ => {\n                bail!(\"Unrecognized language: `{s}`. Expected one of `python`, `pyi`, or `ipynb`.\")\n            }\n        }\n    }\n}\n\nimpl From<Language> for SourceType {\n    fn from(value: Language) -> Self {\n        match value {\n            Language::Python => Self::Python(PySourceType::Python),\n            Language::Ipynb => Self::Python(PySourceType::Ipynb),\n            Language::Pyi => Self::Python(PySourceType::Stub),\n            Language::Markdown => Self::Markdown,\n        }\n    }\n}\n\n#[derive(Clone, Debug, PartialEq, Eq)]\npub struct ExtensionPair {","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_linter/src/settings/types.rs#L427-L463","documentation":"`Language::from_str` parses a file-language setting and only accepts `python`, `pyi`, `ipynb` (plus `md` mapped internally). Any other value, including unrecognized spellings or omitted languages, bails with this message telling the user the accepted set.","triggerScenarios":"Setting an extension-to-language mapping (e.g. `<ext>:<language>` pair) with a language string other than `python`, `pyi`, `ipynb`, or `md` — e.g. `\"jsx:javascript\"` or capitalized/whitespace variants.","commonSituations":"Configuring custom file extensions in ruff.toml and typing `Python`, `py`, or `javascript` instead of the exact tokens; copy-pasting from other tools' configs.","solutions":["Use one of the exact accepted strings: `python`, `pyi`, or `ipynb` (or `md` where supported)","Wrap the value only for whitespace issues — parsing lowercases the input, so case is fine but extra words are not","Choose a different extension mapping if you intended a non-Python language; ruff only supports Python-family source kinds"],"exampleFix":"# before\n\".pyx\" = \"cython\"\n# after\n\".pyx\" = \"python\"","handlingStrategy":"validation","validationCode":"ALLOWED_LANGUAGES = {\"python\", \"pyi\", \"ipynb\", \"md\"}\nassert language.lower().strip() in ALLOWED_LANGUAGES, f\"Unrecognized language: {language}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only python, pyi, ipynb (and md where supported) in extension mappings","Copy accepted values from ruff's documented settings, not other tools","Rely on the lowercase-insensitive match: case is fine, but no extra words or whitespace tokens"],"tags":["ruff","configuration","parsing","language"],"backgroundTag":"invalid-enum-value","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}