Repository navigation
Commit 66af1d6
Don't give reference targets in Buck outputs a Glean file
Summary:
**Problem.** Pyrefly's Glean report (`--report-glean`) records, for each reference and import in an indexed file, the target's name and the file that defines it. That file is the target module's path relative to the working directory. When Pyrefly resolves imports through Buck (e.g. with `fbcode/pyrefly.toml`), generated modules such as Thrift Python packages resolve to build outputs, so the facts name files like `buck-out/.pyrelsp/art/fbcode/<path>/__<target>-python-<x>.thrift__/<hash>/out/gen-python/<pkg>`. In a test of `fbsource.genai.python.pyrefly` with Buck resolution, 285 such paths ended up in `src.File`. They contain a configuration hash, they change from build to build, and Glean never indexes those files, so they are noise in the DB.
The Pyre-based Glean DB `fbsource.fbcode.python`, which the Pyrefly DB `fbsource.fbcode.python.pyrefly` is replacing (T291925475), has no `buck-out` paths: it only writes facts for the source files it indexes, and references reach generated code by name.
**Change.** When the module that defines a reference target is not a source file of the repository (it is under `buck-out/`, or outside the working directory), the reference's definition location now has no file. This state already exists: `DefinitionLocation.file` is an `Option` and is `None` when Pyrefly can't find a definition. The target name is kept, so name-based references (`python.XRefViaName`) are unchanged. The indexed file's own `src.File` is unaffected.
Review: `definition_file_fact` in `pyrefly/lib/report/glean/convert.rs`, its two call sites (`get_definition_location`, `find_definition_for_imported_module`), then the tests.
___
landed-with-radar-review
Differential Revision: D125429038
fbshipit-source-id: 6e69c873cf2ad3930a3b0b87eab9f7d75cd2149a1 parent 96c352b commit 66af1d6
1 file changed
Lines changed: 49 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
168 | 179 | | |
169 | 180 | | |
170 | 181 | | |
| |||
525 | 536 | | |
526 | 537 | | |
527 | 538 | | |
528 | | - | |
| 539 | + | |
529 | 540 | | |
530 | 541 | | |
531 | 542 | | |
| |||
1236 | 1247 | | |
1237 | 1248 | | |
1238 | 1249 | | |
1239 | | - | |
| 1250 | + | |
1240 | 1251 | | |
1241 | 1252 | | |
1242 | 1253 | | |
| |||
1761 | 1772 | | |
1762 | 1773 | | |
1763 | 1774 | | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
1764 | 1779 | | |
1765 | 1780 | | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
1766 | 1813 | | |
1767 | 1814 | | |
1768 | 1815 | | |
| |||
0 commit comments