We are pleased to announce two enhancements to how you navigate code on GitHub. These enhancements are generally available on github.com and can also be found in the new code search technology preview.

Code navigation in pull requests

Until now, code navigation features were only available when viewing files in GitHub’s code browser. As of today, code navigation is also available in the “files changed” tab of each pull request:

jump to definition in a pull request

Clicking on a definition or reference will take you to the code browser for the pull request’s head branch.

This gives you more insight into the impact of your changes, for instance, by letting you see all of the callers that would be affected by a change to a function.

Precise code navigation for Python

Until now, code navigation on GitHub has been “fuzzy” or “search based.” Clicking on a reference would show you all of the definitions in your repository with that name:

search-based code navigation results

While useful, this can result in a lot of noise when viewing definitions and references with a common name.

Starting today, code navigation results for Python are powered by our new stack graphs framework. Stack graphs let us encode detailed information about Python’s name binding rules, allowing us to determine which specific definition each reference refers to:

precise code navigation results

Stack graphs require no additional configuration in your repositories. You do not need to configure any CI workflows or tell us how your Python project is built. It works for all public repositories and for any private repositories that you have access to. If your repository contains Python code, code navigation in that repository is now precise.

For now, code navigation for our other supported languages will continue to provide search-based results. Over the coming months, we will add stack graph support for additional languages, allowing us to show precise code navigation results for them as well. Our stack-graphs library is open source and builds on the Tree-sitter ecosystem of parsers. We will also be publishing information on how language communities can self-serve stack graph support for their languages, should they wish to.

If you would like to learn more about how stack graphs enable precise code navigation with zero configuration, check out our deep dive post and Strange Loop presentation.