Skip to content

Commit

Permalink
fix: consistently set encoding=utf-8 for opening files (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari authored Feb 18, 2025
1 parent 4e2fca6 commit 72e3b14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/rattler_build_conda_compat/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def lint_variable_reference_should_have_space(recipe_dir, recipe_file):
if recipe_dir is not None and os.path.exists(recipe_file):
bad_vars = []
bad_lines = []
with open(recipe_file, "r") as fh:
with open(recipe_file, "r", encoding="utf-8") as fh:
for i, line in enumerate(fh.readlines()):
for m in JINJA_VAR_PAT.finditer(line):
if m.group(1) is not None:
Expand Down
6 changes: 3 additions & 3 deletions src/rattler_build_conda_compat/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(
def parse_recipe(self) -> dict[str, Any]:
recipe_path: Path = Path(self.path) / self._meta_name

yaml_content = load_yaml(recipe_path.read_text())
yaml_content = load_yaml(recipe_path.read_text(encoding="utf-8"))

return render_recipe_with_context(yaml_content)

Expand Down Expand Up @@ -123,8 +123,8 @@ def render_recipes(self, variants) -> List[Dict]:

yaml = _yaml_object()
try:
with tempfile.NamedTemporaryFile(mode="w+") as outfile:
with tempfile.NamedTemporaryFile(mode="w") as variants_file:
with tempfile.NamedTemporaryFile(mode="w+", encoding="utf-8") as outfile:
with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as variants_file:
# dump variants in our variants that will be used to generate recipe
if variants:
yaml.dump(variants, variants_file)
Expand Down

0 comments on commit 72e3b14

Please sign in to comment.