Skip to content

Commit 21ce0b5

Browse files
authored
Merge pull request #361 from projectsyn/fix-pylint-warnings
Set explicit encoding to fix pylint warnings
2 parents 1c83ab3 + 4462b7b commit 21ce0b5

6 files changed

Lines changed: 13 additions & 13 deletions

File tree

commodore/component/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def render_jsonnetfile_json(self, component_params):
214214
str(jsonnetfile_jsonnet),
215215
ext_vars=component_params.get("jsonnetfile_parameters", {}),
216216
)
217-
with open(self._dir / "jsonnetfile.json", "w") as fp:
217+
with open(self._dir / "jsonnetfile.json", "w", encoding="utf-8") as fp:
218218
fp.write(output)
219219

220220

commodore/component/compile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def compile_component(
5555
_prepare_fake_inventory(inv, component, value_files)
5656

5757
# Create class for fake parameters
58-
with open(inv.params_file, "w") as file:
58+
with open(inv.params_file, "w", encoding="utf-8") as file:
5959
file.write(
6060
dedent(
6161
f"""
@@ -85,7 +85,7 @@ def compile_component(
8585
)
8686

8787
# Create test target
88-
with open(inv.target_file(instance_name), "w") as file:
88+
with open(inv.target_file(instance_name), "w", encoding="utf-8") as file:
8989
value_classes = "\n".join([f"- {c.stem}" for c in value_files])
9090
file.write(
9191
dedent(
@@ -104,7 +104,7 @@ def compile_component(
104104
# Fake Argo CD lib
105105
# We plug "fake" Argo CD library here because every component relies on it
106106
# and we don't want to provide it every time when compiling a single component.
107-
with open(inv.lib_dir / "argocd.libjsonnet", "w") as file:
107+
with open(inv.lib_dir / "argocd.libjsonnet", "w", encoding="utf-8") as file:
108108
file.write(
109109
dedent(
110110
"""

commodore/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def api_token(self, api_token):
9898
try:
9999
p = P(api_token)
100100
if p.is_file():
101-
with open(p) as apitoken:
101+
with open(p, encoding="utf-8") as apitoken:
102102
api_token = apitoken.read()
103103
except OSError as e:
104104
# File name too long, assume token is not configured as file

commodore/dependency_mgmt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def write_jsonnetfile(file: P, deps: Iterable):
208208
"legacyImports": True,
209209
}
210210

211-
with open(file, "w") as f:
211+
with open(file, "w", encoding="utf-8") as f:
212212
f.write(json.dumps(data, indent=4))
213213

214214

@@ -249,7 +249,7 @@ def inject_essential_libraries(file: P):
249249
Ensures essential libraries are added to `jsonnetfile.json`.
250250
:param file: The path to `jsonnetfile.json`.
251251
"""
252-
with open(file, "r") as f:
252+
with open(file, "r", encoding="utf-8") as f:
253253
data = json.load(f)
254254

255255
deps = data["dependencies"]
@@ -268,7 +268,7 @@ def inject_essential_libraries(file: P):
268268
},
269269
)
270270

271-
with open(file, "w") as j:
271+
with open(file, "w", encoding="utf-8") as j:
272272
json.dump(data, j, indent=4)
273273

274274

commodore/helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ def yaml_load(file):
4444
"""
4545
Load single-document YAML and return document
4646
"""
47-
with open(file, "r") as f:
47+
with open(file, "r", encoding="utf-8") as f:
4848
return yaml.safe_load(f)
4949

5050

5151
def yaml_load_all(file):
5252
"""
5353
Load multi-document YAML and return documents in list
5454
"""
55-
with open(file, "r") as f:
55+
with open(file, "r", encoding="utf-8") as f:
5656
return list(yaml.safe_load_all(f))
5757

5858

@@ -78,7 +78,7 @@ def yaml_dump(obj, file):
7878
Dump obj as single-document YAML
7979
"""
8080
yaml.add_representer(str, _represent_str)
81-
with open(file, "w") as outf:
81+
with open(file, "w", encoding="utf-8") as outf:
8282
yaml.dump(obj, outf)
8383

8484

@@ -87,7 +87,7 @@ def yaml_dump_all(obj, file):
8787
Dump obj as multi-document YAML
8888
"""
8989
yaml.add_representer(str, _represent_str)
90-
with open(file, "w") as outf:
90+
with open(file, "w", encoding="utf-8") as outf:
9191
yaml.dump_all(obj, outf)
9292

9393

commodore/postprocess/jsonnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _try_path(basedir: P, rel: str):
2828

2929
if not full_path.is_file():
3030
return full_path.name, None
31-
with open(full_path) as f:
31+
with open(full_path, encoding="utf-8") as f:
3232
return full_path.name, f.read()
3333

3434

0 commit comments

Comments
 (0)