Skip to content

Commit

Permalink
Dependabot/pip/pylint 2.11.1 (iterative#6843)
Browse files Browse the repository at this point in the history
* build(deps): Bump pylint from 2.9.6 to 2.11.1

Bumps [pylint](https://github.com/PyCQA/pylint) from 2.9.6 to 2.11.1.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Changelog](https://github.com/PyCQA/pylint/blob/main/ChangeLog)
- [Commits](pylint-dev/pylint@v2.9.6...v2.11.1)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix pylint problems

* Updation after rebase.

* system: use binary mode

* Set remote execution script encoding type locale

* Update dvc/machine/__init__.py

Co-authored-by: Peter Rowlands (변기호) <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ruslan Kuprieiev <[email protected]>
Co-authored-by: Peter Rowlands (변기호) <[email protected]>
  • Loading branch information
4 people authored Oct 20, 2021
1 parent 6de3e73 commit b652670
Showing 40 changed files with 111 additions and 100 deletions.
6 changes: 3 additions & 3 deletions dvc/analytics.py
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ def send(path):
url = "https://analytics.dvc.org"
headers = {"content-type": "application/json"}

with open(path) as fobj:
with open(path, encoding="utf-8") as fobj:
report = json.load(fobj)

report.update(_runtime_info())
@@ -173,13 +173,13 @@ def _find_or_create_user_id():
try:
with Lock(lockfile):
try:
with open(fname) as fobj:
with open(fname, encoding="utf-8") as fobj:
user_id = json.load(fobj)["user_id"]

except (FileNotFoundError, ValueError, KeyError):
user_id = str(uuid.uuid4())

with open(fname, "w") as fobj:
with open(fname, "w", encoding="utf-8") as fobj:
json.dump({"user_id": user_id}, fobj)

return user_id
2 changes: 1 addition & 1 deletion dvc/api.py
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ def make_checkpoint():
root_dir, Repo.DVC_DIR, "tmp", CheckpointTask.SIGNAL_FILE
)

with builtins.open(signal_file, "w") as fobj:
with builtins.open(signal_file, "w", encoding="utf-8") as fobj:
# NOTE: force flushing/writing empty file to disk, otherwise when
# run in certain contexts (pytest) file may not actually be written
fobj.write("")
2 changes: 1 addition & 1 deletion dvc/config.py
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ def init(dvc_dir):
dvc.config.Config: config object.
"""
config_file = os.path.join(dvc_dir, Config.CONFIG)
open(config_file, "w+").close()
open(config_file, "w+", encoding="utf-8").close()
return Config(dvc_dir)

def load(self, validate=True, config=None):
2 changes: 1 addition & 1 deletion dvc/fs/gdrive.py
Original file line number Diff line number Diff line change
@@ -189,7 +189,7 @@ def fs(self):
temporary_save_path = self._gdrive_service_credentials_path

if is_credentials_temp:
with open(temporary_save_path, "w") as cred_file:
with open(temporary_save_path, "w", encoding="utf-8") as cred_file:
cred_file.write(
os.getenv(GDriveFileSystem.GDRIVE_CREDENTIALS_DATA)
)
2 changes: 1 addition & 1 deletion dvc/ignore.py
Original file line number Diff line number Diff line change
@@ -393,7 +393,7 @@ def init(path):
if os.path.exists(dvcignore):
return dvcignore

with open(dvcignore, "w") as fobj:
with open(dvcignore, "w", encoding="utf-8") as fobj:
fobj.write(
"# Add patterns of files dvc should ignore, which could improve\n"
"# the performance. Learn more at\n"
2 changes: 1 addition & 1 deletion dvc/info.py
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ def _get_linktype_support_info(repo):

fname = "." + str(uuid.uuid4())
src = os.path.join(repo.odb.local.cache_dir, fname)
open(src, "w").close()
open(src, "w", encoding="utf-8").close()
dst = os.path.join(repo.root_dir, fname)

cache = []
2 changes: 1 addition & 1 deletion dvc/machine/__init__.py
Original file line number Diff line number Diff line change
@@ -183,7 +183,7 @@ def create(self, name: Optional[str]):
"""Create and start the specified machine instance."""
config, backend = self.get_config_and_backend(name)
if "startup_script" in config:
with open(config["startup_script"]) as fobj:
with open(config["startup_script"], encoding="utf-8") as fobj:
startup_script = fobj.read()
else:
startup_script = DEFAULT_STARTUP_SCRIPT
4 changes: 2 additions & 2 deletions dvc/render/html.py
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ def write(

page_html = None
if template_path:
with open(template_path) as fobj:
with open(template_path, encoding="utf-8") as fobj:
page_html = fobj.read()

document = HTML(page_html, refresh_seconds=refresh_seconds)
@@ -102,6 +102,6 @@ def write(

index = Path(os.path.join(path, "index.html"))

with open(index, "w") as fd:
with open(index, "w", encoding="utf-8") as fd:
fd.write(document.embed())
return index
2 changes: 1 addition & 1 deletion dvc/repo/experiments/executor/local.py
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ def __init__(
def _config(self, cache_dir):
local_config = os.path.join(self.dvc_dir, "config.local")
logger.debug("Writing experiments local config '%s'", local_config)
with open(local_config, "w") as fobj:
with open(local_config, "w", encoding="utf-8") as fobj:
fobj.write(f"[cache]\n dir = {cache_dir}")

def cleanup(self):
8 changes: 6 additions & 2 deletions dvc/repo/plots/template.py
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ def load(self, name: str = None) -> Template:
if name is not None:
template_path = self._find_in_project(name)
if template_path:
with open(template_path, "r") as fd:
with open(template_path, "r", encoding="utf-8") as fd:
content = fd.read()
return Template(content, name)
else:
@@ -195,5 +195,9 @@ def init(self):
.joinpath(template)
.read_text()
)
with open(os.path.join(self.templates_dir, template), "w") as fd:
with open(
os.path.join(self.templates_dir, template),
"w",
encoding="utf-8",
) as fd:
fd.write(content)
4 changes: 2 additions & 2 deletions dvc/rwlock.py
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ def __init__(self, path):
def _edit_rwlock(lock_dir):
path = os.path.join(lock_dir, "rwlock")
try:
with open(path) as fobj:
with open(path, encoding="utf-8") as fobj:
lock = SCHEMA(json.load(fobj))
except FileNotFoundError:
lock = SCHEMA({})
@@ -46,7 +46,7 @@ def _edit_rwlock(lock_dir):
lock["read"] = defaultdict(list, lock["read"])
lock["write"] = defaultdict(dict, lock["write"])
yield lock
with open(path, "w+") as fobj:
with open(path, "w+", encoding="utf-8") as fobj:
json.dump(lock, fobj)


6 changes: 3 additions & 3 deletions dvc/scm/git/__init__.py
Original file line number Diff line number Diff line change
@@ -195,7 +195,7 @@ def ignore_remove(self, path):
if not os.path.exists(gitignore):
return

with open(gitignore) as fobj:
with open(gitignore, encoding="utf-8") as fobj:
lines = fobj.readlines()

filtered = list(filter(lambda x: x.strip() != entry.strip(), lines))
@@ -204,14 +204,14 @@ def ignore_remove(self, path):
os.unlink(gitignore)
return

with open(gitignore, "w") as fobj:
with open(gitignore, "w", encoding="utf-8") as fobj:
fobj.writelines(filtered)

self.track_file(relpath(gitignore))

def _install_hook(self, name):
hook = self._hook_path(name)
with open(hook, "w+") as fobj:
with open(hook, "w+", encoding="utf-8") as fobj:
fobj.write(f"#!/bin/sh\nexec dvc git-hook {name} $@\n")

os.chmod(hook, 0o777)
2 changes: 1 addition & 1 deletion dvc/system.py
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ def _reflink_linux(src, dst):

try:
ret = 255
with open(src) as s, open(dst, "w+") as d:
with open(src, "rb") as s, open(dst, "wb+") as d:
ret = fcntl.ioctl(d.fileno(), FICLONE, s.fileno())
finally:
if ret != 0:
4 changes: 2 additions & 2 deletions dvc/updater.py
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ def _check(self):
self.fetch()
return

with open(self.updater_file) as fobj:
with open(self.updater_file, encoding="utf-8") as fobj:
import json

try:
@@ -105,7 +105,7 @@ def _get_latest_version(self):
logger.debug(msg.format(exc))
return

with open(self.updater_file, "w+") as fobj:
with open(self.updater_file, "w+", encoding="utf-8") as fobj:
json.dump(info, fobj)

def _notify(self, latest: str, pkg: Optional[str] = PKG) -> None:
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ tests =
pydocstyle==6.1.1
jaraco.windows==5.7.0
# pylint requirements
pylint==2.9.6
pylint==2.11.1
# we use this to suppress pytest-related false positives in our tests.
pylint-pytest==1.0.3
# we use this to suppress some messages in tests, eg: foo/bar naming,
2 changes: 1 addition & 1 deletion tests/dir_helpers.py
Original file line number Diff line number Diff line change
@@ -247,7 +247,7 @@ def read_text(self, *args, **kwargs): # pylint: disable=signature-differs
path.name: path.read_text(*args, **kwargs)
for path in self.iterdir()
}
return super().read_text(*args, **kwargs)
return super().read_text(*args, encoding="utf-8", **kwargs)

def hash_to_path_info(self, hash_):
return self / hash_[0:2] / hash_[2:]
4 changes: 2 additions & 2 deletions tests/func/experiments/test_remote.py
Original file line number Diff line number Diff line change
@@ -242,7 +242,7 @@ 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).read() == str(x)
assert open(path, encoding="utf-8").read() == str(x)

remove(dvc.odb.local.cache_dir)

@@ -251,7 +251,7 @@ def test_push_pull_cache(
hash_ = digest(str(x))
path = os.path.join(dvc.odb.local.cache_dir, hash_[:2], hash_[2:])
assert os.path.exists(path)
assert open(path).read() == str(x)
assert open(path, encoding="utf-8").read() == str(x)


def test_auth_error_list(tmp_dir, scm, dvc, http_auth_patch):
2 changes: 1 addition & 1 deletion tests/func/experiments/test_show.py
Original file line number Diff line number Diff line change
@@ -477,7 +477,7 @@ def test_show_with_broken_repo(tmp_dir, scm, dvc, exp_stage, caplog):
exp1 = dvc.experiments.run(exp_stage.addressing, params=["foo=2"])
exp2 = dvc.experiments.run(exp_stage.addressing, params=["foo=3"])

with open("dvc.yaml", "a") as fd:
with open("dvc.yaml", "a", encoding="utf-8") as fd:
fd.write("breaking the yaml!")

result = dvc.experiments.show()
2 changes: 1 addition & 1 deletion tests/func/metrics/test_show.py
Original file line number Diff line number Diff line change
@@ -277,7 +277,7 @@ def test_log_errors(
)
scm.tag("v1")

with open(file, "a") as fd:
with open(file, "a", encoding="utf-8") as fd:
fd.write("\nMALFORMED!")

result = dvc.metrics.show(revs=["v1"])
2 changes: 1 addition & 1 deletion tests/func/params/test_show.py
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@ def test_log_errors(tmp_dir, scm, dvc, capsys, file, error_path):
)

rename = (tmp_dir / file).read_text()
with open(tmp_dir / file, "a") as fd:
with open(tmp_dir / file, "a", encoding="utf-8") as fd:
fd.write("\nmalformed!")

scm.add([PIPELINE_FILE, "params_other.yaml"])
4 changes: 2 additions & 2 deletions tests/func/plots/test_show.py
Original file line number Diff line number Diff line change
@@ -184,7 +184,7 @@ def test_dir_plots(tmp_dir, dvc, run_copy_metrics):


def test_ignore_parsing_error(tmp_dir, dvc, run_copy_metrics):
with open("file", "wb") as fobj:
with open("file", "wb", encoding=None) as fobj:
fobj.write(b"\xc1")

run_copy_metrics("file", "plot_file.json", plots=["plot_file.json"])
@@ -216,7 +216,7 @@ def test_log_errors(
)
scm.tag("v1")

with open(file, "a") as fd:
with open(file, "a", encoding="utf-8") as fd:
fd.write("\nMALFORMED!")

result = dvc.plots.show(onerror=onerror_collect)
6 changes: 3 additions & 3 deletions tests/func/test_add.py
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ def test_add_executable(tmp_dir, dvc):


def test_add_unicode(tmp_dir, dvc):
with open("\xe1", "wb") as fd:
with open("\xe1", "wb", encoding=None) as fd:
fd.write(b"something")

(stage,) = dvc.add("\xe1")
@@ -143,7 +143,7 @@ def test_warn_about_large_directories(self):
# Create a lot of files
for iteration in range(LARGE_DIR_SIZE + 1):
path = os.path.join("large-dir", str(iteration))
with open(path, "w") as fobj:
with open(path, "w", encoding="utf-8") as fobj:
fobj.write(path)

assert main(["add", "--recursive", "large-dir"]) == 0
@@ -581,7 +581,7 @@ def test(self):
foo_stage = relpath(self.FOO + DVC_FILE_SUFFIX)

# corrupt stage file
with open(foo_stage, "a+") as file:
with open(foo_stage, "a+", encoding="utf-8") as file:
file.write("this will break yaml file structure")

self._caplog.clear()
14 changes: 7 additions & 7 deletions tests/func/test_checkout.py
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ def test(self):
cache = self.foo_stage.outs[0].cache_path

os.chmod(cache, 0o644)
with open(cache, "a") as fd:
with open(cache, "a", encoding="utf-8") as fd:
fd.write("1")

with pytest.raises(CheckoutError):
@@ -107,7 +107,7 @@ def test(self):
)

os.chmod(cache, 0o644)
with open(cache, "w+") as fobj:
with open(cache, "w+", encoding="utf-8") as fobj:
fobj.write("1")

with pytest.raises(CheckoutError):
@@ -127,7 +127,7 @@ class CheckoutBase(TestDvcGit):
GIT_IGNORE = ".gitignore"

def commit_data_file(self, fname, content="random text"):
with open(fname, "w") as fd:
with open(fname, "w", encoding="utf-8") as fd:
fd.write(content)
stages = self.dvc.add(fname)
self.assertEqual(len(stages), 1)
@@ -136,7 +136,7 @@ def commit_data_file(self, fname, content="random text"):
self.dvc.scm.commit("adding " + fname)

def read_ignored(self):
with open(self.GIT_IGNORE) as f:
with open(self.GIT_IGNORE, encoding="utf-8") as f:
return [s.strip("\n") for s in f.readlines()]

def outs_info(self, stage):
@@ -188,7 +188,7 @@ def test(self, mock_prompt):
stage = stages[0]

working_dir_change = os.path.join(self.DATA_DIR, "not_cached.txt")
with open(working_dir_change, "w") as f:
with open(working_dir_change, "w", encoding="utf-8") as f:
f.write("not_cached")

ret = main(["checkout", stage.relpath])
@@ -204,7 +204,7 @@ def test_force(self, mock_prompt):
stage = stages[0]

working_dir_change = os.path.join(self.DATA_DIR, "not_cached.txt")
with open(working_dir_change, "w") as f:
with open(working_dir_change, "w", encoding="utf-8") as f:
f.write("not_cached")

ret = main(["checkout", stage.relpath])
@@ -610,7 +610,7 @@ def test_checkout_stats_on_failure(tmp_dir, dvc, scm):
# corrupt cache
cache = stage.outs[0].cache_path
os.chmod(cache, 0o644)
with open(cache, "a") as fd:
with open(cache, "a", encoding="utf-8") as fd:
fd.write("destroy cache")

scm.checkout("HEAD~")
4 changes: 2 additions & 2 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ def _check_status(status, **kwargs):
dvc.cloud.pull(foo_hashes)
assert os.path.exists(cache)
assert os.path.isfile(cache)
with open(cache) as fd:
with open(cache, encoding="utf-8") as fd:
assert fd.read() == "foo"

dvc.cloud.pull(dir_hashes)
@@ -166,7 +166,7 @@ def test_cloud_cli(tmp_dir, dvc, remote):
assert os.path.isfile("foo")
assert os.path.isdir("data_dir")

with open(cache) as fd:
with open(cache, encoding="utf-8") as fd:
assert fd.read() == "foo"
assert os.path.isfile(cache_dir)

Loading

0 comments on commit b652670

Please sign in to comment.