mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
ruff: ignore complex functions and remove dvc.utils.fs.makedirs (#8795)
We may want to prevent any new functions from getting complex.
This commit is contained in:
@@ -22,7 +22,6 @@ from dvc.repo.experiments.utils import (
|
||||
exp_refs_by_rev,
|
||||
)
|
||||
from dvc.utils import relpath
|
||||
from dvc.utils.fs import makedirs
|
||||
from dvc.utils.serialize import YAMLFileCorruptedError
|
||||
|
||||
LOCK_CONTENTS = {
|
||||
@@ -447,7 +446,7 @@ def test_show_running_workspace(
|
||||
"workspace",
|
||||
f"workspace{BaseExecutor.INFOFILE_EXT}",
|
||||
)
|
||||
makedirs(os.path.dirname(pidfile), True)
|
||||
os.makedirs(os.path.dirname(pidfile), exist_ok=True)
|
||||
(tmp_dir / pidfile).dump_json(info.asdict())
|
||||
(tmp_dir / lock_file).dump_json(LOCK_CONTENTS)
|
||||
|
||||
@@ -524,7 +523,7 @@ def test_show_running_tempdir(tmp_dir, scm, dvc, exp_stage, mocker):
|
||||
)
|
||||
info = make_executor_info(location=BaseExecutor.DEFAULT_LOCATION)
|
||||
pidfile = queue.get_infofile_path(stash_rev)
|
||||
makedirs(os.path.dirname(pidfile), True)
|
||||
os.makedirs(os.path.dirname(pidfile), exist_ok=True)
|
||||
(tmp_dir / pidfile).dump_json(info.asdict())
|
||||
mock_fetch = mocker.patch.object(
|
||||
dvc.experiments.tempdir_queue,
|
||||
@@ -557,7 +556,7 @@ def test_show_running_celery(tmp_dir, scm, dvc, exp_stage, mocker):
|
||||
)
|
||||
info = make_executor_info(location=BaseExecutor.DEFAULT_LOCATION)
|
||||
pidfile = queue.get_infofile_path(entries[0].stash_rev)
|
||||
makedirs(os.path.dirname(pidfile), True)
|
||||
os.makedirs(os.path.dirname(pidfile), exist_ok=True)
|
||||
(tmp_dir / pidfile).dump_json(info.asdict())
|
||||
|
||||
results = dvc.experiments.show()
|
||||
@@ -599,7 +598,7 @@ def test_show_running_checkpoint(tmp_dir, scm, dvc, checkpoint_stage, mocker):
|
||||
location=TempDirExecutor.DEFAULT_LOCATION,
|
||||
status=TaskStatus.RUNNING,
|
||||
)
|
||||
makedirs(os.path.dirname(pidfile), True)
|
||||
os.makedirs(os.path.dirname(pidfile), exist_ok=True)
|
||||
(tmp_dir / pidfile).dump_json(info.asdict())
|
||||
|
||||
mocker.patch.object(
|
||||
|
||||
@@ -6,7 +6,7 @@ from scmrepo.git import Git
|
||||
from dvc.external_repo import CLONES, external_repo
|
||||
from dvc.testing.tmp_dir import make_subrepo
|
||||
from dvc.utils import relpath
|
||||
from dvc.utils.fs import makedirs, remove
|
||||
from dvc.utils.fs import remove
|
||||
from dvc_data.hashfile.build import build
|
||||
from dvc_data.hashfile.transfer import transfer
|
||||
|
||||
@@ -200,7 +200,7 @@ def test_subrepos_are_ignored(tmp_dir, erepo_dir):
|
||||
# clear cache to test saving to cache
|
||||
cache_dir = tmp_dir / repo.odb.local.path
|
||||
remove(cache_dir)
|
||||
makedirs(cache_dir)
|
||||
os.makedirs(cache_dir)
|
||||
|
||||
staging, _, obj = build(
|
||||
repo.odb.local,
|
||||
|
||||
@@ -9,7 +9,6 @@ from dvc.odbmgr import ODBManager
|
||||
from dvc.repo import Repo
|
||||
from dvc.repo.get import GetDVCFileError
|
||||
from dvc.testing.tmp_dir import make_subrepo
|
||||
from dvc.utils.fs import makedirs
|
||||
|
||||
|
||||
def test_get_repo_file(tmp_dir, erepo_dir):
|
||||
@@ -170,7 +169,7 @@ def test_get_to_dir(tmp_dir, erepo_dir, dname):
|
||||
with erepo_dir.chdir():
|
||||
erepo_dir.dvc_gen("file", "contents", commit="create file")
|
||||
|
||||
makedirs(dname, exist_ok=True)
|
||||
os.makedirs(dname, exist_ok=True)
|
||||
|
||||
Repo.get(os.fspath(erepo_dir), "file", dname)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from dvc.fs import system
|
||||
from dvc.odbmgr import ODBManager
|
||||
from dvc.stage.exceptions import StagePathNotFoundError
|
||||
from dvc.testing.tmp_dir import make_subrepo
|
||||
from dvc.utils.fs import makedirs, remove
|
||||
from dvc.utils.fs import remove
|
||||
|
||||
|
||||
def test_import(tmp_dir, scm, dvc, erepo_dir):
|
||||
@@ -376,7 +376,7 @@ def test_download_error_pulling_imported_stage(
|
||||
|
||||
@pytest.mark.parametrize("dname", [".", "dir", "dir/subdir"])
|
||||
def test_import_to_dir(dname, tmp_dir, dvc, erepo_dir):
|
||||
makedirs(dname, exist_ok=True)
|
||||
os.makedirs(dname, exist_ok=True)
|
||||
|
||||
with erepo_dir.chdir():
|
||||
erepo_dir.dvc_gen("foo", "foo content", commit="create foo")
|
||||
|
||||
@@ -12,7 +12,6 @@ from dvc.dvcfile import Dvcfile
|
||||
from dvc.exceptions import InvalidArgumentError
|
||||
from dvc.stage import Stage
|
||||
from dvc.testing.workspace_tests import TestImport as _TestImport
|
||||
from dvc.utils.fs import makedirs
|
||||
|
||||
|
||||
def test_cmd_import(tmp_dir, dvc):
|
||||
@@ -74,7 +73,7 @@ def test_import_url_to_dir(dname, tmp_dir, dvc):
|
||||
tmp_dir.gen({"data_dir": {"file": "file content"}})
|
||||
src = os.path.join("data_dir", "file")
|
||||
|
||||
makedirs(dname, exist_ok=True)
|
||||
os.makedirs(dname, exist_ok=True)
|
||||
|
||||
stage = dvc.imp_url(src, dname)
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import os
|
||||
import stat
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc.utils.fs import makedirs
|
||||
|
||||
|
||||
@pytest.mark.skipif(os.name == "nt", reason="Not supported for Windows.")
|
||||
def test_makedirs_permissions(tmp_dir):
|
||||
dir_mode = 0o755
|
||||
intermediate_dir = "тестовая-директория"
|
||||
test_dir = os.path.join(intermediate_dir, "data")
|
||||
|
||||
assert not os.path.exists(intermediate_dir)
|
||||
|
||||
makedirs(test_dir, mode=dir_mode)
|
||||
|
||||
assert stat.S_IMODE(os.stat(test_dir).st_mode) == dir_mode
|
||||
assert stat.S_IMODE(os.stat(intermediate_dir).st_mode) == dir_mode
|
||||
@@ -8,7 +8,6 @@ from dvc.utils import relpath
|
||||
from dvc.utils.fs import (
|
||||
BasePathNotInCheckedPathException,
|
||||
contains_symlink_up_to,
|
||||
makedirs,
|
||||
path_isin,
|
||||
remove,
|
||||
)
|
||||
@@ -155,5 +154,5 @@ def test_contains_symlink_case_sensitive_posix():
|
||||
def test_makedirs(tmp_dir):
|
||||
path = os.path.join(tmp_dir, "directory")
|
||||
|
||||
makedirs(path)
|
||||
os.makedirs(path)
|
||||
assert os.path.isdir(path)
|
||||
|
||||
Reference in New Issue
Block a user