Skip to content

Commit 6b81f9f

Browse files
rubmarymeta-codesync[bot]
authored andcommitted
Adding additional xrefs to imports
Summary: The pyrefly indexer does not always link the cross references with the corresponding import. This is causing issues for dead code bots. See https://www.internalfb.com/diff/D91318413?transaction_fbid=4540263059554165 and https://fb.workplace.com/groups/factsaboutcode/permalink/2782833315399232/ I started adding xrefs in D91681470, but we are still missing xrefs when we have transitive imports and when pyrefly returns the import as definition. Reviewed By: donsbot Differential Revision: D92156801 fbshipit-source-id: 3107ccf271bb6fb56642c891ce240f3ad53fa93e
1 parent 32fa888 commit 6b81f9f

4 files changed

Lines changed: 50 additions & 0 deletions

File tree

glean/lang/python-pyrefly/tests/regression/without_dynamic_import/core/xrefs/declaration_reference.out

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,19 @@
417417
"target": { "func": { "key": { "name": { "key": "lib.helper_func" } } } }
418418
}
419419
},
420+
{
421+
"key": {
422+
"source": { "func": { "key": { "name": { "key": "main.f" } } } },
423+
"target": {
424+
"imp": {
425+
"key": {
426+
"as_name": { "key": "lib.func" },
427+
"from_name": { "key": "big_lib.big_func" }
428+
}
429+
}
430+
}
431+
}
432+
},
420433
{
421434
"key": {
422435
"source": { "func": { "key": { "name": { "key": "main.f" } } } },
@@ -1189,6 +1202,19 @@
11891202
"target": { "func": { "key": { "name": { "key": "main.f" } } } }
11901203
}
11911204
},
1205+
{
1206+
"key": {
1207+
"source": { "module": { "key": { "name": { "key": "main" } } } },
1208+
"target": {
1209+
"imp": {
1210+
"key": {
1211+
"as_name": { "key": "lib.func" },
1212+
"from_name": { "key": "big_lib.big_func" }
1213+
}
1214+
}
1215+
}
1216+
}
1217+
},
11921218
{
11931219
"key": {
11941220
"source": { "module": { "key": { "name": { "key": "main" } } } },

glean/lang/python-pyrefly/tests/regression/without_dynamic_import/core/xrefs/xrefs_via_name_by_file.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@
550550
"source": { "length": 4, "start": 377 },
551551
"target": { "key": "big_lib.big_func" }
552552
},
553+
{
554+
"source": { "length": 4, "start": 377 },
555+
"target": { "key": "lib.func" }
556+
},
553557
{
554558
"source": { "length": 4, "start": 377 },
555559
"target": { "key": "main.func" }

glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/declaration_uses.out

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@
188188
"span": { "length": 3, "start": 327 }
189189
}
190190
},
191+
{
192+
"key": {
193+
"declaration": {
194+
"imp": {
195+
"key": {
196+
"as_name": { "key": "mod_b.helper.only_indirectly" },
197+
"from_name": { "key": "mod_b.util.only_indirectly" }
198+
}
199+
}
200+
},
201+
"file": {
202+
"key": "glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/mod_a/__init__.py"
203+
},
204+
"span": { "length": 15, "start": 363 }
205+
}
206+
},
191207
{
192208
"key": {
193209
"declaration": { "module": { "key": { "name": { "key": "mod_b" } } } },

glean/lang/python-pyrefly/tests/regression/without_dynamic_import/declaration_uses/simple/xrefs_via_name_by_file.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@
7878
"source": { "length": 15, "start": 363 },
7979
"target": { "key": "mod_a.only_indirectly" }
8080
},
81+
{
82+
"source": { "length": 15, "start": 363 },
83+
"target": { "key": "mod_b.helper.only_indirectly" }
84+
},
8185
{
8286
"source": { "length": 15, "start": 363 },
8387
"target": { "key": "mod_b.util.only_indirectly" }

0 commit comments

Comments
 (0)