mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-27 10:26:26 +00:00
[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.
This commit is contained in:
parent
3771f1567c
commit
697998f836
7 changed files with 15 additions and 17 deletions
|
|
@ -15,8 +15,10 @@ use ruff_text_size::{Ranged, TextRange, TextSize};
|
|||
use ty_python_semantic::HasDefinition;
|
||||
use ty_python_semantic::ImportAliasResolution;
|
||||
use ty_python_semantic::ResolvedDefinition;
|
||||
use ty_python_semantic::types::definitions_for_keyword_argument;
|
||||
use ty_python_semantic::types::{Type, call_signature_details};
|
||||
use ty_python_semantic::types::Type;
|
||||
use ty_python_semantic::types::ide_support::{
|
||||
call_signature_details, definitions_for_keyword_argument,
|
||||
};
|
||||
use ty_python_semantic::{
|
||||
HasType, SemanticModel, definitions_for_imported_symbol, definitions_for_name,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ use ruff_db::parsed::parsed_module;
|
|||
use ruff_python_ast::visitor::source_order::{self, SourceOrderVisitor, TraversalSignal};
|
||||
use ruff_python_ast::{AnyNodeRef, Expr, Stmt};
|
||||
use ruff_text_size::{Ranged, TextRange, TextSize};
|
||||
use ty_python_semantic::types::{Type, inlay_hint_function_argument_details};
|
||||
use ty_python_semantic::types::Type;
|
||||
use ty_python_semantic::types::ide_support::inlay_hint_function_argument_details;
|
||||
use ty_python_semantic::{HasType, SemanticModel};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ use ruff_python_ast::{
|
|||
use ruff_text_size::{Ranged, TextLen, TextRange};
|
||||
use std::ops::Deref;
|
||||
use ty_python_semantic::{
|
||||
HasType, SemanticModel,
|
||||
semantic_index::definition::DefinitionKind,
|
||||
types::{Type, definition_kind_for_name},
|
||||
HasType, SemanticModel, semantic_index::definition::DefinitionKind, types::Type,
|
||||
types::ide_support::definition_kind_for_name,
|
||||
};
|
||||
|
||||
// This module walks the AST and collects a set of "semantic tokens" for a file
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use ruff_text_size::{Ranged, TextRange, TextSize};
|
|||
use ty_python_semantic::ResolvedDefinition;
|
||||
use ty_python_semantic::SemanticModel;
|
||||
use ty_python_semantic::semantic_index::definition::Definition;
|
||||
use ty_python_semantic::types::{
|
||||
use ty_python_semantic::types::ide_support::{
|
||||
CallSignatureDetails, call_signature_details, find_active_signature_from_details,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use crate::semantic_index::definition::Definition;
|
|||
use crate::semantic_index::scope::FileScopeId;
|
||||
use crate::semantic_index::semantic_index;
|
||||
use crate::types::ide_support::all_declarations_and_bindings;
|
||||
use crate::types::ide_support::{Member, all_members};
|
||||
use crate::types::{Type, binding_type, infer_scope_types};
|
||||
|
||||
pub struct SemanticModel<'db> {
|
||||
|
|
@ -193,7 +194,7 @@ impl<'db> SemanticModel<'db> {
|
|||
let builtin = module.is_known(self.db, KnownModule::Builtins);
|
||||
|
||||
let mut completions = vec![];
|
||||
for crate::types::Member { name, ty } in crate::types::all_members(self.db, ty) {
|
||||
for Member { name, ty } in all_members(self.db, ty) {
|
||||
completions.push(Completion {
|
||||
name,
|
||||
ty: Some(ty),
|
||||
|
|
@ -226,7 +227,7 @@ impl<'db> SemanticModel<'db> {
|
|||
/// Returns completions for symbols available in a `object.<CURSOR>` context.
|
||||
pub fn attribute_completions(&self, node: &ast::ExprAttribute) -> Vec<Completion<'db>> {
|
||||
let ty = node.value.inferred_type(self);
|
||||
crate::types::all_members(self.db, ty)
|
||||
all_members(self.db, ty)
|
||||
.into_iter()
|
||||
.map(|member| Completion {
|
||||
name: member.name,
|
||||
|
|
|
|||
|
|
@ -55,12 +55,6 @@ use crate::types::generics::{
|
|||
GenericContext, PartialSpecialization, Specialization, bind_typevar, typing_self,
|
||||
walk_generic_context,
|
||||
};
|
||||
pub use crate::types::ide_support::{
|
||||
CallSignatureDetails, Member, MemberWithDefinition, all_members, call_signature_details,
|
||||
definition_kind_for_name, definitions_for_attribute, definitions_for_imported_symbol,
|
||||
definitions_for_keyword_argument, definitions_for_name, find_active_signature_from_details,
|
||||
inlay_hint_function_argument_details,
|
||||
};
|
||||
use crate::types::infer::infer_unpack_types;
|
||||
use crate::types::mro::{Mro, MroError, MroIterator};
|
||||
pub(crate) use crate::types::narrow::infer_narrowing_constraint;
|
||||
|
|
@ -89,7 +83,7 @@ mod display;
|
|||
mod enums;
|
||||
mod function;
|
||||
mod generics;
|
||||
pub(crate) mod ide_support;
|
||||
pub mod ide_support;
|
||||
mod infer;
|
||||
mod instance;
|
||||
mod mro;
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ use crate::types::diagnostic::{
|
|||
};
|
||||
use crate::types::display::DisplaySettings;
|
||||
use crate::types::generics::GenericContext;
|
||||
use crate::types::ide_support::all_members;
|
||||
use crate::types::narrow::ClassInfoConstraintFunction;
|
||||
use crate::types::signatures::{CallableSignature, Signature};
|
||||
use crate::types::visitor::any_over_type;
|
||||
|
|
@ -82,7 +83,7 @@ use crate::types::{
|
|||
ClassLiteral, ClassType, DeprecatedInstance, DynamicType, FindLegacyTypeVarsVisitor,
|
||||
HasRelationToVisitor, IsEquivalentVisitor, KnownClass, KnownInstanceType, NormalizedVisitor,
|
||||
SpecialFormType, TrackedConstraintSet, Truthiness, Type, TypeMapping, TypeRelation,
|
||||
UnionBuilder, all_members, binding_type, todo_type, walk_signature,
|
||||
UnionBuilder, binding_type, todo_type, walk_signature,
|
||||
};
|
||||
use crate::{Db, FxOrderSet, ModuleName, resolve_module};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue