{"record":{"id":"4e6d072d68611dfa","repo":"astral-sh/ruff","slug":"expected-markdown-text","errorCode":null,"errorMessage":"expected markdown text","messagePattern":"expected markdown text","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_linter/src/source_kind.rs","lineNumber":75,"sourceCode":"\n    pub fn expect_python(self) -> String {\n        match self {\n            SourceKind::Python { code, is_stub: _ } => code,\n            _ => panic!(\"expected python code\"),\n        }\n    }\n\n    pub fn expect_ipy_notebook(self) -> Notebook {\n        match self {\n            SourceKind::IpyNotebook(notebook) => *notebook,\n            _ => panic!(\"expected ipy notebook\"),\n        }\n    }\n\n    pub fn expect_markdown(self) -> String {\n        match self {\n            SourceKind::Markdown(code) => code,\n            _ => panic!(\"expected markdown text\"),\n        }\n    }\n\n    pub fn py_source_type(&self) -> PySourceType {\n        match self {\n            Self::IpyNotebook(_) => PySourceType::Ipynb,\n            Self::Python { is_stub: true, .. } => PySourceType::Stub,\n            Self::Python { is_stub: false, .. } => PySourceType::Python,\n            Self::Markdown(_) => PySourceType::Python,\n        }\n    }\n\n    #[must_use]\n    pub(crate) fn updated(&self, new_source: String, source_map: &SourceMap) -> Self {\n        match self {\n            SourceKind::IpyNotebook(notebook) => {\n                let mut cloned = notebook.clone();\n                cloned.update(source_map, new_source);","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_linter/src/source_kind.rs#L57-L93","documentation":"Panics in SourceKind::expect_markdown because the wrapped source is Python code or an ipynb notebook rather than Markdown text. Like the sibling expect_* methods, it asserts the caller already knows the variant; other kinds are a caller bug.","triggerScenarios":"Thrown at crates/ruff_linter/src/source_kind.rs:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use as_markdown() or a match to confirm the variant first","Only call expect_markdown on sources known to be Markdown"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}