{"record":{"id":"ea4b61852c67e58d","repo":"astral-sh/ruff","slug":"expected-importnames-aliases-importnames-star","errorCode":null,"errorMessage":"Expected ImportNames::Aliases | ImportNames::Star","messagePattern":"Expected ImportNames::Aliases \\| ImportNames::Star","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_mock_import.rs","lineNumber":259,"sourceCode":"                },\n                dot: Dot {\n                    whitespace_before: ParenthesizableWhitespace::default(),\n                    whitespace_after: ParenthesizableWhitespace::default(),\n                },\n                lpar: vec![],\n                rpar: vec![],\n            })));\n\n            let mut content = tree.codegen_stylist(stylist);\n            if !mock_aliases.is_empty() {\n                content.push_str(&stylist.line_ending());\n                content.push_str(indent);\n                content.push_str(&format_mocks(mock_aliases, indent, stylist));\n            }\n            content\n        })\n    } else {\n        panic!(\"Expected ImportNames::Aliases | ImportNames::Star\");\n    }\n}\n\n/// UP026\npub(crate) fn deprecated_mock_attribute(checker: &Checker, attribute: &ast::ExprAttribute) {\n    if !checker.semantic().seen_module(Modules::MOCK) {\n        return;\n    }\n\n    if UnqualifiedName::from_expr(&attribute.value)\n        .is_some_and(|qualified_name| matches!(qualified_name.segments(), [\"mock\", \"mock\"]))\n    {\n        let mut diagnostic = checker.report_diagnostic(\n            DeprecatedMockImport {\n                reference_type: MockReference::Attribute,\n            },\n            attribute.value.range(),\n        );","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/astral-sh/ruff/blob/15f3fe6b15a5f00172f34b0f542f8ea277f5a586/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_mock_import.rs#L241-L277","documentation":"An anyhow bail! in the deprecated-mock-import fixer's format_import_from: while rebuilding the import statement, the CST node's import names were neither a list of aliases nor a star, which the fixer's reconstruction logic cannot represent. The fix is abandoned and reported as failed.","triggerScenarios":"Thrown at crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_mock_import.rs:257 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Extend format_import_from to handle the unexpected ImportNames shape","Skip the autofix when the import form is not reconstructable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"15f3fe6b15a5f00172f34b0f542f8ea277f5a586","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}