Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/ty_python_semantic/src/types/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ impl<'db> NominalInstanceType<'db> {
/// Returns the name of the class this is an instance of.
///
/// For example, for an instance of `builtins.str`, this returns `"str"`.
///
/// As of 2026-02-16, this method is not used in any crates in the Ruff
/// repo, but is exposed as a public API for external users of
/// `ty_python_semantic`.
pub fn class_name(&self, db: &'db dyn Db) -> &'db Name {
self.class(db).name(db)
}
Expand All @@ -249,6 +253,10 @@ impl<'db> NominalInstanceType<'db> {
/// For example, for an instance of `pathlib.Path`, this returns
/// `Some("pathlib")`. Returns `None` if the class's file cannot be resolved
/// to a known module (e.g. for classes defined in scripts or notebooks).
///
/// As of 2026-02-16, this method is not used in any crates in the Ruff
/// repo, but is exposed as a public API for external users of
/// `ty_python_semantic`.
pub fn class_module_name(&self, db: &'db dyn Db) -> Option<&'db ModuleName> {
let file = self.class(db).class_literal(db).file(db);
file_to_module(db, file).map(|module| module.name(db))
Expand Down