Skip to content

Commit 697998f

Browse files
authored
[ty] Do not re-export ide_support attributes from types (#20769)
## Summary The `types` module currently re-exports a lot of functions and data types from `types::ide_support`. One of these is called `Member`, a name that is overloaded several times already. And I'd like to add one more `Member` struct soon. Making the whole `ide_support` module public seems cleaner to me, anyway. ## Test Plan Pure refactoring.
1 parent 3771f15 commit 697998f

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

crates/ty_ide/src/goto.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ use ruff_text_size::{Ranged, TextRange, TextSize};
1515
use ty_python_semantic::HasDefinition;
1616
use ty_python_semantic::ImportAliasResolution;
1717
use ty_python_semantic::ResolvedDefinition;
18-
use ty_python_semantic::types::definitions_for_keyword_argument;
19-
use ty_python_semantic::types::{Type, call_signature_details};
18+
use ty_python_semantic::types::Type;
19+
use ty_python_semantic::types::ide_support::{
20+
call_signature_details, definitions_for_keyword_argument,
21+
};
2022
use ty_python_semantic::{
2123
HasType, SemanticModel, definitions_for_imported_symbol, definitions_for_name,
2224
};

crates/ty_ide/src/inlay_hints.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use ruff_db::parsed::parsed_module;
66
use ruff_python_ast::visitor::source_order::{self, SourceOrderVisitor, TraversalSignal};
77
use ruff_python_ast::{AnyNodeRef, Expr, Stmt};
88
use ruff_text_size::{Ranged, TextRange, TextSize};
9-
use ty_python_semantic::types::{Type, inlay_hint_function_argument_details};
9+
use ty_python_semantic::types::Type;
10+
use ty_python_semantic::types::ide_support::inlay_hint_function_argument_details;
1011
use ty_python_semantic::{HasType, SemanticModel};
1112

1213
#[derive(Debug, Clone)]

crates/ty_ide/src/semantic_tokens.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ use ruff_python_ast::{
1313
use ruff_text_size::{Ranged, TextLen, TextRange};
1414
use std::ops::Deref;
1515
use ty_python_semantic::{
16-
HasType, SemanticModel,
17-
semantic_index::definition::DefinitionKind,
18-
types::{Type, definition_kind_for_name},
16+
HasType, SemanticModel, semantic_index::definition::DefinitionKind, types::Type,
17+
types::ide_support::definition_kind_for_name,
1918
};
2019

2120
// This module walks the AST and collects a set of "semantic tokens" for a file

crates/ty_ide/src/signature_help.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ruff_text_size::{Ranged, TextRange, TextSize};
1717
use ty_python_semantic::ResolvedDefinition;
1818
use ty_python_semantic::SemanticModel;
1919
use ty_python_semantic::semantic_index::definition::Definition;
20-
use ty_python_semantic::types::{
20+
use ty_python_semantic::types::ide_support::{
2121
CallSignatureDetails, call_signature_details, find_active_signature_from_details,
2222
};
2323

crates/ty_python_semantic/src/semantic_model.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::semantic_index::definition::Definition;
1212
use crate::semantic_index::scope::FileScopeId;
1313
use crate::semantic_index::semantic_index;
1414
use crate::types::ide_support::all_declarations_and_bindings;
15+
use crate::types::ide_support::{Member, all_members};
1516
use crate::types::{Type, binding_type, infer_scope_types};
1617

1718
pub struct SemanticModel<'db> {
@@ -193,7 +194,7 @@ impl<'db> SemanticModel<'db> {
193194
let builtin = module.is_known(self.db, KnownModule::Builtins);
194195

195196
let mut completions = vec![];
196-
for crate::types::Member { name, ty } in crate::types::all_members(self.db, ty) {
197+
for Member { name, ty } in all_members(self.db, ty) {
197198
completions.push(Completion {
198199
name,
199200
ty: Some(ty),
@@ -226,7 +227,7 @@ impl<'db> SemanticModel<'db> {
226227
/// Returns completions for symbols available in a `object.<CURSOR>` context.
227228
pub fn attribute_completions(&self, node: &ast::ExprAttribute) -> Vec<Completion<'db>> {
228229
let ty = node.value.inferred_type(self);
229-
crate::types::all_members(self.db, ty)
230+
all_members(self.db, ty)
230231
.into_iter()
231232
.map(|member| Completion {
232233
name: member.name,

crates/ty_python_semantic/src/types.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ use crate::types::generics::{
5555
GenericContext, PartialSpecialization, Specialization, bind_typevar, typing_self,
5656
walk_generic_context,
5757
};
58-
pub use crate::types::ide_support::{
59-
CallSignatureDetails, Member, MemberWithDefinition, all_members, call_signature_details,
60-
definition_kind_for_name, definitions_for_attribute, definitions_for_imported_symbol,
61-
definitions_for_keyword_argument, definitions_for_name, find_active_signature_from_details,
62-
inlay_hint_function_argument_details,
63-
};
6458
use crate::types::infer::infer_unpack_types;
6559
use crate::types::mro::{Mro, MroError, MroIterator};
6660
pub(crate) use crate::types::narrow::infer_narrowing_constraint;
@@ -89,7 +83,7 @@ mod display;
8983
mod enums;
9084
mod function;
9185
mod generics;
92-
pub(crate) mod ide_support;
86+
pub mod ide_support;
9387
mod infer;
9488
mod instance;
9589
mod mro;

crates/ty_python_semantic/src/types/function.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ use crate::types::diagnostic::{
7474
};
7575
use crate::types::display::DisplaySettings;
7676
use crate::types::generics::GenericContext;
77+
use crate::types::ide_support::all_members;
7778
use crate::types::narrow::ClassInfoConstraintFunction;
7879
use crate::types::signatures::{CallableSignature, Signature};
7980
use crate::types::visitor::any_over_type;
@@ -82,7 +83,7 @@ use crate::types::{
8283
ClassLiteral, ClassType, DeprecatedInstance, DynamicType, FindLegacyTypeVarsVisitor,
8384
HasRelationToVisitor, IsEquivalentVisitor, KnownClass, KnownInstanceType, NormalizedVisitor,
8485
SpecialFormType, TrackedConstraintSet, Truthiness, Type, TypeMapping, TypeRelation,
85-
UnionBuilder, all_members, binding_type, todo_type, walk_signature,
86+
UnionBuilder, binding_type, todo_type, walk_signature,
8687
};
8788
use crate::{Db, FxOrderSet, ModuleName, resolve_module};
8889

0 commit comments

Comments
 (0)