{"record":{"id":"37c84e56f3e8bf35","repo":"astral-sh/ruff","slug":"will-return-some-when-called-on-class-literal","errorCode":null,"errorMessage":"Will return Some() when called on class literal","messagePattern":"Will return Some\\(\\) when called on class literal","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_python_semantic/src/types/class/typed_dict.rs","lineNumber":1086,"sourceCode":"    )\n}\n\npub(super) fn typed_dict_fallback_class_member<'db>(\n    db: &'db dyn Db,\n    env: &ProgramEnvironment<'db>,\n    module: TypingModule,\n    lookup_policy: MemberLookupPolicy,\n    name: &str,\n) -> PlaceAndQualifiers<'db> {\n    let fallback = match module {\n        TypingModule::Typing => KnownClass::TypedDictFallback,\n        TypingModule::TypingExtensions => KnownClass::ExtensionTypedDictFallback,\n    };\n\n    fallback\n        .to_class_literal(db, env)\n        .find_name_in_mro_with_policy(db, env, name, lookup_policy)\n        .expect(\"Will return Some() when called on class literal\")\n}\n\npub(super) fn typed_dict_class_member<'db>(\n    db: &'db dyn Db,\n    env: &ProgramEnvironment<'db>,\n    class: ClassType<'db>,\n    module: TypingModule,\n    lookup_policy: MemberLookupPolicy,\n    name: &str,\n) -> PlaceAndQualifiers<'db> {\n    let self_class = class.class_literal(db);\n\n    typed_dict_inherited_class_member(\n        db,\n        env,\n        TypedDictType::new(class),\n        module,\n        lookup_policy,","sourceCodeStart":1068,"sourceCodeEnd":1104,"githubUrl":"https://github.com/astral-sh/ruff/blob/d1087a4b9e03d253a88703f34e0869ee4b805456/crates/ty_python_semantic/src/types/class/typed_dict.rs#L1068-L1104","documentation":"`typed_dict_fallback_class_member` resolves a member on the TypedDict fallback class literal (from typing or typing_extensions, depending on `module`). The stated invariant: an MRO member lookup on a class literal always returns Some because the MRO terminates in `object`. The expect fires when the loaded typeshed does not contain the requested member anywhere in the fallback class's MRO.","triggerScenarios":"Member access on a TypedDict-shaped type that falls back to the stub class while the active typeshed's `typing.pyi`/`typing_extensions` fallback stubs lack the member (and `object` does not provide it either).","commonSituations":"Custom, stripped, or outdated typeshed directories; mixing a typeshed snapshot with a ty binary from a different era; typeshed API changes where a member moved or was renamed while ty still requests the old name.","solutions":["Run ty with the bundled vendored typeshed instead of a custom one.","Update ty so its member requests match the typeshed version it vendors.","If a custom typeshed is mandatory, sync it to the version ty's snapshot is pinned to and verify the missing member exists in the stub.","Report the member name (visible in the panic backtrace) upstream if the bundled setup panics."],"exampleFix":"# before: fallback stub missing the member ty looks up\n# <typeshed>/stdlib/typing.pyi: class TypedDict(metaclass=_TypedDictMeta): ...\n\n# after: restore/patch the stub so the member resolves, e.g.\n# class TypedDict(metaclass=_TypedDictMeta):\n#     def __call__(self, *args, **kwargs) -> Any: ...","handlingStrategy":"validation","validationCode":"# verify the member exists in the stubs ty will load (substitute the member\n# from your panic backtrace for __call__):\ngrep -rn 'def __call__' <typeshed>/stdlib/typing.pyi <typeshed>/stdlib/builtins.pyi\n# no hits anywhere in the fallback MRO means this panic is expected","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the typeshed version vendored with your ty build; do not override it with older stubs.","Keep ty and any custom stub checkout in sync when typeshed APIs move.","Capture the member name from the backtrace before reporting; it identifies the stub gap."],"tags":["rust","panic","expect","ty","typeddict","typeshed","member-lookup"],"backgroundTag":"typeshed-stub-mismatch","analyzedSha":"d1087a4b9e03d253a88703f34e0869ee4b805456","analyzedAt":"2026-08-20T16:33:49.445Z","contentChangedAt":"2026-08-20T16:33:49.445Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}