uv icon indicating copy to clipboard operation
uv copied to clipboard

Update activate_this.py to use runpy instead of exec in the docstring

Open FredStober opened this issue 1 year ago • 1 comments

Summary

runpy.run_path was added in python 2.7 and 3.2 - and every python that is not EOL supports it.

It is arguably nicer to read and the path is only given once in the command.

At least right now, runpy - unlike exec with S102 - is not flagged by any bandit-derived ruff check. (I guess because it loads from a file instead of a simple string...)

Because of the import, it is also not a one-liner anymore. (But that could be fixed with an import('runpy').run_path...)

Test Plan

import runpy runpy.run_path('/path/to/venv/bin/activate_this.py')

FredStober avatar May 07 '24 23:05 FredStober

Welcome to the project and thanks for contributing! I'm not sure this merits diverging from virtualenv — we copy these implementations from there and the less divergence we have the easier it is for us to maintain. Maybe it'd be worth checking if they're interested in it upstream?

zanieb avatar May 08 '24 00:05 zanieb

The updated documentation was merged into the upstream virtualenv library - and this PR brings the same change to uv

FredStober avatar May 13 '24 01:05 FredStober