highlight user frames in interactive debugger #1421
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a new
library
CSS class to frames that look like they are from built-in or installed library code. This removes the blue background from those frames, emphasizing the frames that come from the user's code. Clicking to expand the line will add the background color back so that it's easy to pick out from the surrounding context.Library frames are detected by comparing their filename to all paths returned by
sysconfig.get_paths()
. Other projects like tbvaccine check against the current working directory, but for the common setup where the env is a directory under the project, this would identify installed packages as user code.If the detection thinks all or no frames are library code, it reverts to the old behavior of highlighting everything. This could happen, for example, if a project is installed in its virtualenv without using
-e
.Unfortunately, virtualenv ships its own
site.py
which does not set these correctly, so code that was not installed to the env's site-packages dir (built-ins, system packages) will look like user code. This doesn't happen with venv or tools like Poetry and Pipenv which use it.Due to the issue with virtualenv, which is what tox uses, I couldn't think of a reliable test for this, so this remains "untested" for now, although manual testing showed it working as expected.
Closes #1165