Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions pyrefly/lib/binding/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,6 @@ impl Bindings {
infer_param_types_from_docstring: bool,
use_shape_comments_and_stubs: bool,
) -> Self {
let module_range = x.range;
let dunder_all_entries = exports
.dunder_all_names()
.filter_map(|(_, name, content_range)| {
Expand Down Expand Up @@ -1284,7 +1283,9 @@ impl Bindings {
let module_deletes = scope_trace.module_deletes().clone();
let functools_wrapper_mutation = bind_functools_wrapper_mutation(
&mut builder.table,
module_range,
// An empty range keeps the literal's type trace from shadowing an expression that
// spans the whole module
TextRange::default(),
builder.has_functools_wrapper_mutation,
);
builder.table.insert(
Expand Down
12 changes: 12 additions & 0 deletions pyrefly/lib/test/tsp/tsp_interaction/get_type_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,18 @@ fn test_get_computed_type_list_is_class() {
tsp.shutdown();
}

#[test]
fn test_get_computed_type_expression_spanning_whole_module() {
// Without a trailing newline, the expression's range equals the module's range.
let (mut tsp, file_uri, snapshot) = setup_project("[1, 2, 3]");

let result = get_computed_type_range_ok(&mut tsp, &file_uri, 0, 0, 0, 9, snapshot);
let name = result.pointer("/declaration/name").and_then(|v| v.as_str());
assert_eq!(name, Some("list"), "Expected class name 'list'");

tsp.shutdown();
}

#[test]
fn test_get_computed_type_function_is_function_type() {
// A function definition should produce a FunctionType with CALLABLE flag
Expand Down
Loading