From 35b568dd6b85dec04a639466fefebf2bbb1bb3bb Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Wed, 8 Oct 2025 13:54:59 -0400 Subject: [PATCH] [ty_test] Move HoverOutput to hover module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the HoverOutput type from check_output.rs to hover.rs where it logically belongs. The check_output module should only contain the CheckOutput enum and sorting infrastructure, while hover-specific types belong in the hover module. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- crates/ty_test/src/check_output.rs | 10 +--------- crates/ty_test/src/hover.rs | 11 ++++++++++- crates/ty_test/src/matcher.rs | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/crates/ty_test/src/check_output.rs b/crates/ty_test/src/check_output.rs index df26bdcd63..84c1e0fc5e 100644 --- a/crates/ty_test/src/check_output.rs +++ b/crates/ty_test/src/check_output.rs @@ -5,17 +5,9 @@ use ruff_db::diagnostic::Diagnostic; use ruff_source_file::{LineIndex, OneIndexed}; -use ruff_text_size::TextSize; use std::ops::Range; -/// A hover result for testing hover assertions. -#[derive(Debug, Clone)] -pub(crate) struct HoverOutput { - /// The position where hover was requested - pub(crate) offset: TextSize, - /// The inferred type at that position - pub(crate) inferred_type: String, -} +use crate::hover::HoverOutput; /// Represents either a diagnostic or a hover result for matching against assertions. #[derive(Debug, Clone)] diff --git a/crates/ty_test/src/hover.rs b/crates/ty_test/src/hover.rs index 1c4fb90321..4022a33e63 100644 --- a/crates/ty_test/src/hover.rs +++ b/crates/ty_test/src/hover.rs @@ -3,7 +3,6 @@ //! This module provides functionality to extract hover assertions from comments, //! infer types at specified positions, and generate hover check outputs for matching. -use crate::check_output::{CheckOutput, HoverOutput}; use ruff_db::files::File; use ruff_db::parsed::parsed_module; use ruff_db::source::{line_index, source_text}; @@ -12,8 +11,18 @@ use ruff_python_ast::AnyNodeRef; use ruff_text_size::{Ranged, TextSize}; use ty_python_semantic::{HasType, SemanticModel}; +use crate::check_output::CheckOutput; use crate::db::Db; +/// A hover result for testing hover assertions. +#[derive(Debug, Clone)] +pub(crate) struct HoverOutput { + /// The position where hover was requested + pub(crate) offset: TextSize, + /// The inferred type at that position + pub(crate) inferred_type: String, +} + /// Find the AST node with minimal range that fully contains the given offset. fn find_covering_node<'a>(root: AnyNodeRef<'a>, offset: TextSize) -> Option> { struct Visitor<'a> { diff --git a/crates/ty_test/src/matcher.rs b/crates/ty_test/src/matcher.rs index cc6cf8ac4e..27f6889695 100644 --- a/crates/ty_test/src/matcher.rs +++ b/crates/ty_test/src/matcher.rs @@ -12,7 +12,8 @@ use ruff_db::source::{SourceText, line_index, source_text}; use ruff_source_file::{LineIndex, OneIndexed}; use crate::assertion::{InlineFileAssertions, ParsedAssertion, UnparsedAssertion}; -use crate::check_output::{CheckOutput, HoverOutput, LineCheckOutputs, SortedCheckOutputs}; +use crate::check_output::{CheckOutput, LineCheckOutputs, SortedCheckOutputs}; +use crate::hover::HoverOutput; use crate::db::Db; #[derive(Debug, Default)]