Skip to content

Commit 9678e58

Browse files
committed
Less inderection
1 parent 2b1c798 commit 9678e58

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

relenv/common.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,20 @@
88
import http.client
99
import json
1010
import logging
11-
import os as _os
11+
import os
1212
import pathlib
1313
import platform
1414
import queue
1515
import selectors
1616
import shutil
17-
import subprocess as _subprocess
18-
import sys as _sys
17+
import subprocess
18+
import sys
1919
import tarfile
2020
import textwrap
2121
import threading
2222
import time
2323
from typing import IO, Any, BinaryIO, Iterable, Literal, Mapping, Optional, Union, cast
2424

25-
# Re-export frequently monkeypatched modules for type checking.
26-
os = _os
27-
subprocess = _subprocess
28-
sys = _sys
29-
3025
# relenv package version
3126
__version__ = "0.21.2"
3227

tests/test_common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_get_toolchain(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch)
160160
data_dir = tmp_path / "data"
161161
triplet = "aarch64-linux-gnu"
162162
monkeypatch.setattr(relenv.common, "DATA_DIR", data_dir, raising=False)
163-
monkeypatch.setattr(relenv.common.sys, "platform", "linux", raising=False)
163+
monkeypatch.setattr(sys, "platform", "linux")
164164
monkeypatch.setattr(
165165
relenv.common, "get_triplet", lambda machine=None, plat=None: triplet
166166
)
@@ -178,7 +178,7 @@ def test_get_toolchain_linux_existing(tmp_path: pathlib.Path) -> None:
178178
toolchain_path = data_dir / "toolchain" / triplet
179179
toolchain_path.mkdir(parents=True)
180180
with patch("relenv.common.DATA_DIR", data_dir), patch(
181-
"relenv.common.sys.platform", "linux"
181+
"sys.platform", "linux"
182182
), patch("relenv.common.get_triplet", return_value=triplet), patch.dict(
183183
os.environ,
184184
{"RELENV_TOOLCHAIN_CACHE": str(data_dir / "toolchain")},
@@ -193,7 +193,7 @@ def test_get_toolchain_no_arch(
193193
data_dir = tmp_path / "data"
194194
triplet = "x86_64-linux-gnu"
195195
monkeypatch.setattr(relenv.common, "DATA_DIR", data_dir, raising=False)
196-
monkeypatch.setattr(relenv.common.sys, "platform", "linux", raising=False)
196+
monkeypatch.setattr(sys, "platform", "linux")
197197
monkeypatch.setattr(
198198
relenv.common, "get_triplet", lambda machine=None, plat=None: triplet
199199
)
@@ -445,7 +445,7 @@ def test_sanitize_sys_path_with_editable_paths(tmp_path: pathlib.Path) -> None:
445445

446446

447447
def test_makepath_oserror() -> None:
448-
with patch("relenv.common.os.path.abspath", side_effect=OSError):
448+
with patch("os.path.abspath", side_effect=OSError):
449449
result, case = makepath("foo", "Bar")
450450
expected = os.path.join("foo", "Bar")
451451
assert result == expected

0 commit comments

Comments
 (0)