Skip to content

Commit 7676e43

Browse files
committed
Refactor single use function
1 parent 4fc638d commit 7676e43

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

opentelemetry-api/src/opentelemetry/auto_instrument/auto_instrument.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,22 @@
1616

1717
from shutil import which
1818
from os import environ, execl
19-
from os.path import dirname, pathsep
19+
from os.path import dirname, join
2020
from sys import argv
2121

2222

23-
def _add_bootstrap_to_pythonpath(bootstrap_dir):
24-
"""
25-
Add our bootstrap directory to the head of $PYTHONPATH to ensure
26-
it is loaded before program code
27-
"""
28-
python_path = environ.get('PYTHONPATH', '')
23+
def run() -> None:
2924

30-
if python_path:
31-
new_path = '%s%s%s' % (
32-
bootstrap_dir, pathsep, environ['PYTHONPATH'])
33-
environ['PYTHONPATH'] = new_path
34-
else:
35-
environ['PYTHONPATH'] = bootstrap_dir
25+
bootstrap_dir = dirname(__file__)
26+
python_path = environ.get("PYTHONPATH", None)
3627

28+
# Add our bootstrap directory to the head of $PYTHONPATH to ensure
29+
# it is loaded before program code
30+
if python_path is not None:
31+
environ["PYTHONPATH"] = join(bootstrap_dir, python_path)
32+
else:
33+
environ["PYTHONPATH"] = bootstrap_dir
3734

38-
def run() -> None:
39-
_add_bootstrap_to_pythonpath(dirname(__file__))
4035
python3 = which(argv[1])
4136
execl(python3, python3, *argv[2:]) # type: ignore
4237

0 commit comments

Comments
 (0)