Skip to content

Commit d398380

Browse files
committed
add documents
1 parent 16a097c commit d398380

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/ty_python_semantic/src/types.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10840,6 +10840,7 @@ impl<'db> PEP695TypeAliasType<'db> {
1084010840
semantic_index(db, scope.file(db)).expect_single_definition(type_alias_stmt_node)
1084110841
}
1084210842

10843+
/// The RHS type of a PEP-695 style type alias with specialization applied.
1084310844
#[salsa::tracked(cycle_fn=value_type_cycle_recover, cycle_initial=value_type_cycle_initial, heap_size=ruff_memory_usage::heap_size)]
1084410845
pub(crate) fn value_type(self, db: &'db dyn Db) -> Type<'db> {
1084510846
let value_type = self.raw_value_type(db);
@@ -10855,6 +10856,16 @@ impl<'db> PEP695TypeAliasType<'db> {
1085510856
}
1085610857
}
1085710858

10859+
/// The RHS type of a PEP-695 style type alias with *no* specialization applied.
10860+
///
10861+
/// ## Warning
10862+
///
10863+
/// This uses the semantic index to find the definition of the type alias. This means that if the
10864+
/// calling query is not in the same file as this type alias is defined in, then this will create
10865+
/// a cross-module dependency directly on the full AST which will lead to cache
10866+
/// over-invalidation.
10867+
/// This method also calls the type inference functions, and since type aliases can have recursive structures,
10868+
/// we should be careful not to create infinite recursions in this method (or make it tracked if necessary).
1085810869
pub(crate) fn raw_value_type(self, db: &'db dyn Db) -> Type<'db> {
1085910870
let scope = self.rhs_scope(db);
1086010871
let module = parsed_module(db, scope.file(db)).load(db);

0 commit comments

Comments
 (0)