Skip to content

Commit dc32d54

Browse files
nejchJohnVillalovos
authored andcommitted
chore: consistently use open() encoding and file descriptor
1 parent 618267c commit dc32d54

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

gitlab/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ def _parse_value(v: Any) -> Any:
257257
# If the user-provided value starts with @, we try to read the file
258258
# path provided after @ as the real value. Exit on any error.
259259
try:
260-
with open(v[1:]) as fl:
261-
return fl.read()
260+
with open(v[1:]) as f:
261+
return f.read()
262262
except Exception as e:
263263
sys.stderr.write(f"{e}\n")
264264
sys.exit(1)

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
def get_version() -> str:
88
version = ""
9-
with open("gitlab/_version.py") as f:
9+
with open("gitlab/_version.py", "r", encoding="utf-8") as f:
1010
for line in f:
1111
if line.startswith("__version__"):
1212
version = eval(line.split("=")[-1])
1313
break
1414
return version
1515

1616

17-
with open("README.rst", "r") as readme_file:
18-
readme = readme_file.read()
17+
with open("README.rst", "r", encoding="utf-8") as f:
18+
readme = f.read()
1919

2020
setup(
2121
name="python-gitlab",

tests/functional/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def set_token(container, fixture_dir):
8787
logging.info("Creating API token.")
8888
set_token_rb = fixture_dir / "set_token.rb"
8989

90-
with open(set_token_rb, "r") as f:
90+
with open(set_token_rb, "r", encoding="utf-8") as f:
9191
set_token_command = f.read().strip()
9292

9393
rails_command = [
@@ -206,7 +206,7 @@ def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, fixture_
206206
private_token = {token}
207207
api_version = 4"""
208208

209-
with open(config_file, "w") as f:
209+
with open(config_file, "w", encoding="utf-8") as f:
210210
f.write(config)
211211

212212
return config_file

tests/unit/objects/test_todos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
@pytest.fixture()
1414
def json_content(fixture_dir):
15-
with open(fixture_dir / "todo.json", "r") as json_file:
16-
todo_content = json_file.read()
15+
with open(fixture_dir / "todo.json", "r", encoding="utf-8") as f:
16+
todo_content = f.read()
1717
return json.loads(todo_content)
1818

1919

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy