{"record":{"id":"84d879b2c3949f7b","repo":"astral-sh/ruff","slug":"object-should-always-be-a-non-generic-class-in-t","errorCode":null,"errorMessage":"`object` should always be a non-generic class in typeshed","messagePattern":"`object` should always be a non-generic class in typeshed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_python_semantic/src/types/class.rs","lineNumber":631,"sourceCode":")]\npub enum ClassLiteral<'db> {\n    /// A class defined via a `class` statement.\n    Static(StaticClassLiteral<'db>),\n    /// A class created dynamically via `type(name, bases, dict)`.\n    Dynamic(DynamicClassLiteral<'db>),\n    /// A class created via `collections.namedtuple()` or `typing.NamedTuple()`.\n    DynamicNamedTuple(DynamicNamedTupleLiteral<'db>),\n    /// A class created via functional `TypedDict(\"Name\", {...})`.\n    DynamicTypedDict(DynamicTypedDictLiteral<'db>),\n    /// A class created via functional enum syntax, e.g., `Enum(\"Color\", \"RED GREEN BLUE\")`.\n    DynamicEnum(DynamicEnumLiteral<'db>),\n}\n\n#[salsa::tracked]\nimpl<'db> ClassLiteral<'db> {\n    /// Return a `ClassLiteral` representing the class `builtins.object`\n    pub(super) fn object(db: &'db dyn Db, env: &ProgramEnvironment<'db>) -> Self {\n        KnownClass::Object\n            .to_class_literal(db, env)\n            .as_class_literal()\n            .expect(\"`object` should always be a non-generic class in typeshed\")\n    }\n\n    pub(super) fn recursive_type_normalized_impl(\n        self,\n        db: &'db dyn Db,\n        env: &ProgramEnvironment<'db>,\n        div: Type<'db>,\n        nested: bool,\n    ) -> Option<Self> {\n        match self {\n            Self::Dynamic(dynamic) => Some(Self::Dynamic(\n                dynamic.recursive_type_normalized_impl(db, env, div, nested)?,\n            )),\n            Self::DynamicNamedTuple(named_tuple) => Some(Self::DynamicNamedTuple(\n                named_tuple.recursive_type_normalized_impl(db, env, div, nested)?,","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/astral-sh/ruff/blob/15f3fe6b15a5f00172f34b0f542f8ea277f5a586/crates/ty_python_semantic/src/types/class.rs#L613-L649","documentation":"`ClassLiteral::object` resolves `builtins.object` from the active `ProgramEnvironment` and asserts it is a plain, non-generic class literal, as typeshed guarantees. The expect fires when the loaded typeshed does not define `object` as a resolvable non-generic class. This is an environment problem (missing/broken/foreign stubs), not something user Python code can cause.","triggerScenarios":"Running checks with a custom, minimal, outdated, or corrupted typeshed whose `stdlib/builtins.pyi` is missing or does not declare a plain `class object:`; mixing a typeshed snapshot from one ty version with the binary of another; a failed/partial extraction of the vendored typeshed.","commonSituations":"Pointing ty at a custom stub directory; offline/containers builds that strip the bundled typeshed; upgrading ty in place while an old vendored snapshot remains on disk.","solutions":["Run ty with its bundled default typeshed (remove any custom typeshed/search-path override) and re-check.","Inspect the typeshed ty loads: `stdlib/builtins.pyi` must contain `class object:` with no type parameters.","Upgrade/downgrade ty so the binary and its vendored typeshed come from the same release.","If a custom typeshed is required, restore a standard typeshed checkout (same version the vendored snapshot is pinned to)."],"exampleFix":"# before: custom typeshed where stdlib/builtins.pyi is missing or has\n#   class object[T]: ...\n# after: stdlib/builtins.pyi must declare the plain class\n#   class object:\n#       __module__: str\n#       ...","handlingStrategy":"validation","validationCode":"# before pointing ty at a custom typeshed, verify the stub it will load:\ngrep -n '^class object' <typeshed>/stdlib/builtins.pyi\n# empty output, or a generic `class object[T]`, means this panic is guaranteed","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer ty's bundled typeshed; only override it with a full standard checkout.","Never mix a typeshed snapshot from one ty release with a binary from another.","Verify custom stub sets contain stdlib/builtins.pyi with a plain `class object:` before wiring them in."],"tags":["rust","panic","expect","ty","typeshed","environment","object"],"backgroundTag":"typeshed-stub-mismatch","analyzedSha":"15f3fe6b15a5f00172f34b0f542f8ea277f5a586","analyzedAt":"2026-08-20T16:33:49.445Z","contentChangedAt":"2026-08-20T16:33:49.445Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}