From 433dba02e0d4462ae84a73d8699fe7f3e07aa410 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Thu, 28 Jul 2022 22:11:19 -0700 Subject: [PATCH] chore: make code PEP597 compliant Use `encoding="utf-8"` in `open()` and open-like functions. https://peps.python.org/pep-0597/ --- gitlab/config.py | 2 +- tests/meta/test_v4_objects_imported.py | 2 +- tests/unit/objects/test_packages.py | 2 +- tests/unit/test_config.py | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gitlab/config.py b/gitlab/config.py index dc577fce0..152ec7e2e 100644 --- a/gitlab/config.py +++ b/gitlab/config.py @@ -135,7 +135,7 @@ def __init__( def _parse_config(self) -> None: _config = configparser.ConfigParser() - _config.read(self._files) + _config.read(self._files, encoding="utf-8") if self.gitlab_id and not _config.has_section(self.gitlab_id): raise GitlabDataError( diff --git a/tests/meta/test_v4_objects_imported.py b/tests/meta/test_v4_objects_imported.py index 083443aa7..f158a3340 100644 --- a/tests/meta/test_v4_objects_imported.py +++ b/tests/meta/test_v4_objects_imported.py @@ -13,7 +13,7 @@ def test_verify_v4_objects_imported() -> None: assert len(gitlab.v4.objects.__path__) == 1 init_files: Set[str] = set() - with open(gitlab.v4.objects.__file__, "r") as in_file: + with open(gitlab.v4.objects.__file__, "r", encoding="utf-8") as in_file: for line in in_file.readlines(): if line.startswith("from ."): init_files.add(line.rstrip()) diff --git a/tests/unit/objects/test_packages.py b/tests/unit/objects/test_packages.py index 79f1d1b34..cee3fa8bf 100644 --- a/tests/unit/objects/test_packages.py +++ b/tests/unit/objects/test_packages.py @@ -276,7 +276,7 @@ def test_delete_project_package_file_from_package_file_object( def test_upload_generic_package(tmp_path, project, resp_upload_generic_package): path = tmp_path / file_name - path.write_text(file_content) + path.write_text(file_content, encoding="utf-8") package = project.generic_packages.upload( package_name=package_name, package_version=package_version, diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index c4fcbef61..0e3324aab 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -290,7 +290,8 @@ def test_data_from_helper(m_open, monkeypatch, tmp_path): #!/bin/sh echo "secret" """ - ) + ), + encoding="utf-8", ) helper.chmod(0o755)