From e28dfa7a011ec19d77e82d6bf1df90ad4726b22a Mon Sep 17 00:00:00 2001 From: Fred Stober Date: Thu, 9 May 2024 23:22:29 +0200 Subject: [PATCH 1/3] Update activate_this.py documentation to use runpy instead of exec (#2716) --- src/virtualenv/activation/python/activate_this.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/virtualenv/activation/python/activate_this.py b/src/virtualenv/activation/python/activate_this.py index befe8f405..388e00153 100644 --- a/src/virtualenv/activation/python/activate_this.py +++ b/src/virtualenv/activation/python/activate_this.py @@ -1,7 +1,8 @@ """ Activate virtualenv for current interpreter: -Use exec(open(this_file).read(), {'__file__': this_file}). +import runpy +runpy.run_path(this_file) This can be used when you must use an existing Python interpreter, not the virtualenv bin/python. """ # noqa: D415 @@ -15,7 +16,7 @@ try: abs_file = os.path.abspath(__file__) except NameError as exc: - msg = "You must use exec(open(this_file).read(), {'__file__': this_file})" + msg = "You must use import runpy; runpy.run_path(this_file)" raise AssertionError(msg) from exc bin_dir = os.path.dirname(abs_file) From 60233a121599e3376bcadb16033b033af351a2df Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Thu, 9 May 2024 23:22:54 +0200 Subject: [PATCH 2/3] Apply ruff/bugbear new rules (#2718) --- src/virtualenv/__main__.py | 2 +- src/virtualenv/create/debug.py | 2 +- src/virtualenv/create/describe.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/virtualenv/__main__.py b/src/virtualenv/__main__.py index 2dc97c787..d0979a665 100644 --- a/src/virtualenv/__main__.py +++ b/src/virtualenv/__main__.py @@ -21,7 +21,7 @@ def run(args=None, options=None, env=None): print(f"subprocess call failed for {exception.cmd} with code {exception.code}") # noqa: T201 print(exception.out, file=sys.stdout, end="") # noqa: T201 print(exception.err, file=sys.stderr, end="") # noqa: T201 - raise SystemExit(exception.code) # noqa: TRY200, B904 + raise SystemExit(exception.code) # noqa: B904 class LogSession: diff --git a/src/virtualenv/create/debug.py b/src/virtualenv/create/debug.py index 3f54685a3..bc33367c8 100644 --- a/src/virtualenv/create/debug.py +++ b/src/virtualenv/create/debug.py @@ -95,7 +95,7 @@ def run(): # noqa: PLR0912 except (ValueError, TypeError) as exception: # pragma: no cover sys.stderr.write(repr(exception)) sys.stdout.write(repr(result)) # pragma: no cover - raise SystemExit(1) # noqa: TRY200, B904 # pragma: no cover + raise SystemExit(1) # noqa: B904 # pragma: no cover if __name__ == "__main__": diff --git a/src/virtualenv/create/describe.py b/src/virtualenv/create/describe.py index 726305547..1ee250cbc 100644 --- a/src/virtualenv/create/describe.py +++ b/src/virtualenv/create/describe.py @@ -7,7 +7,7 @@ from virtualenv.info import IS_WIN -class Describe(ABC): +class Describe: """Given a host interpreter tell us information about what the created interpreter might look like.""" suffix = ".exe" if IS_WIN else "" From 7864fde3c3e64fa59186e95c5832d8fc8016a029 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 9 May 2024 14:23:05 -0700 Subject: [PATCH 3/3] [pre-commit.ci] pre-commit autoupdate (#2715) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6a9ff02de..97d7d01ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: - id: pyproject-fmt additional_dependencies: ["tox>=4.12.1"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.4.2" + rev: "v0.4.3" hooks: - id: ruff-format - id: ruff