mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
pre-commit update: flake8/ruff/pyupgrade/black/isort (#8813)
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
[flake8]
|
||||
ignore=
|
||||
E203, # Whitespace before ':'
|
||||
E266, # Too many leading '#' for block comment
|
||||
W503, # Line break occurred before a binary operator
|
||||
P1, # unindexed parameters in the str.format, see:
|
||||
# Whitespace before ':'
|
||||
E203
|
||||
# Too many leading '#' for block comment
|
||||
E266
|
||||
# Line break occurred before a binary operator
|
||||
W503
|
||||
# unindexed parameters in the str.format, see:
|
||||
# https://pypi.org/project/flake8-string-format/
|
||||
P1
|
||||
# use `!r` instead of surrounding by quotes
|
||||
B028
|
||||
max_line_length = 79
|
||||
max-complexity = 10
|
||||
select = B,C,E,F,W,T4,B902,T,P
|
||||
|
||||
@@ -6,7 +6,7 @@ ci:
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.3.0
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
- id: check-case-conflict
|
||||
@@ -29,21 +29,21 @@ repos:
|
||||
- id: beautysh
|
||||
args: ["-i", "2"]
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.2.0
|
||||
rev: v3.3.1
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args:
|
||||
- --py38-plus
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.10.0
|
||||
rev: 22.12.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.10.1
|
||||
rev: 5.11.4
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||
rev: 'v0.0.218'
|
||||
rev: 'v0.0.222'
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: ["--force-exclude"]
|
||||
@@ -53,11 +53,10 @@ repos:
|
||||
- id: codespell
|
||||
additional_dependencies: ["tomli"]
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 5.0.4
|
||||
rev: 6.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies:
|
||||
- flake8-broken-line
|
||||
- flake8-bugbear
|
||||
- flake8-comprehensions
|
||||
- flake8-debugger
|
||||
|
||||
+2
-2
@@ -142,8 +142,8 @@ class Config(dict):
|
||||
dvc.config.Config: config object.
|
||||
"""
|
||||
config_file = os.path.join(dvc_dir, Config.CONFIG)
|
||||
open(config_file, "w+", encoding="utf-8").close()
|
||||
return Config(dvc_dir)
|
||||
with open(config_file, "w+", encoding="utf-8"):
|
||||
return Config(dvc_dir)
|
||||
|
||||
def load(self, validate=True, config=None):
|
||||
"""Loads config from all the config files.
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ class ManagedProcess(AbstractContextManager):
|
||||
"Appending output to '%s'",
|
||||
self.stdout_path,
|
||||
)
|
||||
self._stdout = open(self.stdout_path, "ab")
|
||||
self._stdout = open(self.stdout_path, "ab") # noqa: SIM115
|
||||
try:
|
||||
self._proc = subprocess.Popen(
|
||||
self.args,
|
||||
|
||||
@@ -26,7 +26,7 @@ def parse_yaml(text, path, typ="safe"):
|
||||
|
||||
yaml = YAML(typ=typ)
|
||||
with reraise(_YAMLError, YAMLFileCorruptedError(path)):
|
||||
return yaml.load(text) or {} # noqa: S506
|
||||
return yaml.load(text) or {}
|
||||
|
||||
|
||||
def parse_yaml_for_update(text, path):
|
||||
|
||||
+1
-1
@@ -163,7 +163,7 @@ line_length = 79
|
||||
line-length = 79
|
||||
target-version = "py38"
|
||||
show-source = true
|
||||
ignore = ["S101", "SIM105", "SIM108", "SIM110", "SIM111", "SIM117", "A003", "ARG002"]
|
||||
ignore = ["S101", "SIM105", "SIM108", "SIM110", "SIM111", "SIM117", "A003", "ARG002", "PLR2004"]
|
||||
select = ["F", "E", "W", "C90", "UP", "YTT", "S", "BLE", "B", "A", "C4", "T10", "ISC", "ICN", "T20", "PT003", "PT008", "PT009", "PT010", "PT015", "PT016", "PT017", "PT020", "PT021", "PT024", "PT025", "PT026", "Q", "RET501", "RET504", "SIM", "ARG", "TID", "PGH", "PLC", "PLE", "PLR", "PLW", "PIE", "RUF"]
|
||||
# external flake8 codes that should be preserved
|
||||
external = ["B301", "B024", "C901", "E302", "F401", "W601"]
|
||||
|
||||
@@ -326,7 +326,8 @@ def test_push_pull_cache(
|
||||
hash_ = digest(str(x))
|
||||
path = os.path.join(local_remote.url, hash_[:2], hash_[2:])
|
||||
assert os.path.exists(path)
|
||||
assert open(path, encoding="utf-8").read() == str(x)
|
||||
with open(path, encoding="utf-8") as f:
|
||||
assert f.read() == str(x)
|
||||
|
||||
remove(dvc.odb.local.path)
|
||||
|
||||
@@ -335,7 +336,8 @@ def test_push_pull_cache(
|
||||
hash_ = digest(str(x))
|
||||
path = os.path.join(dvc.odb.local.path, hash_[:2], hash_[2:])
|
||||
assert os.path.exists(path)
|
||||
assert open(path, encoding="utf-8").read() == str(x)
|
||||
with open(path, encoding="utf-8") as f:
|
||||
assert f.read() == str(x)
|
||||
|
||||
|
||||
def test_auth_error_list(tmp_dir, scm, dvc, http_auth_patch):
|
||||
|
||||
@@ -262,11 +262,11 @@ class TestRunBadWdir:
|
||||
|
||||
def test_not_dir(self, tmp_dir, dvc):
|
||||
with pytest.raises(StagePathNotDirectoryError):
|
||||
path = os.path.join(tmp_dir, str(uuid.uuid4()))
|
||||
os.mkdir(path)
|
||||
path = os.path.join(path, str(uuid.uuid4()))
|
||||
open(path, "a", encoding="utf-8").close()
|
||||
dvc.run(cmd="command", wdir=path, single_stage=True)
|
||||
path = tmp_dir / str(uuid.uuid4())
|
||||
path.mkdir()
|
||||
path = path / str(uuid.uuid4())
|
||||
path.touch()
|
||||
dvc.run(cmd="command", wdir=os.fspath(path), single_stage=True)
|
||||
|
||||
|
||||
class TestRunBadName:
|
||||
|
||||
Reference in New Issue
Block a user