Skip to content

Commit

Permalink
Fix 'unspecified-encoding' lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Artturin authored and mergify[bot] committed Oct 19, 2023
1 parent fabc492 commit e301309
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nixpkgs_review/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def read_github_token() -> str | None:
if token:
return token
try:
with open(hub_config_path()) as f:
with open(hub_config_path(), encoding="utf-8") as f:
for line in f:
# Allow substring match as hub uses yaml. Example string we match:
# " - oauth_token: ghp_abcdefghijklmnopqrstuvwxyzABCDEF1234\n"
Expand Down
2 changes: 1 addition & 1 deletion nixpkgs_review/cli/post_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def post_result_command(args: argparse.Namespace) -> None:
warn(f"Report not found in {report}. Are you in a nixpkgs-review nix-shell?")
sys.exit(1)

with open(report) as f:
with open(report, encoding="utf-8") as f:
report_text = f.read()
github_client.comment_issue(pr, report_text)
2 changes: 1 addition & 1 deletion nixpkgs_review/nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def nix_build(
def write_shell_expression(
filename: Path, attrs: list[str], system: str, nixpkgs_config: Path
) -> None:
with open(filename, "w+") as f:
with open(filename, "w+", encoding="utf-8") as f:
f.write(
f"""{{ pkgs ? import ./nixpkgs {{ system = \"{system}\"; config = import {nixpkgs_config}; }} }}:
with pkgs;
Expand Down
8 changes: 5 additions & 3 deletions nixpkgs_review/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def write_error_logs(attrs: list[Attr], directory: Path) -> None:
for path in [f"{attr.drv_path}^*", attr.path]:
if not path:
continue
with open(logs.ensure().joinpath(attr.name + ".log"), "w+") as f:
with open(
logs.ensure().joinpath(attr.name + ".log"), "w+", encoding="utf-8"
) as f:
nix_log = subprocess.run(
[
"nix",
Expand Down Expand Up @@ -122,10 +124,10 @@ def built_packages(self) -> list[str]:
return [a.name for a in self.built]

def write(self, directory: Path, pr: int | None) -> None:
with open(directory.joinpath("report.md"), "w+") as f:
with open(directory.joinpath("report.md"), "w+", encoding="utf-8") as f:
f.write(self.markdown(pr))

with open(directory.joinpath("report.json"), "w+") as f:
with open(directory.joinpath("report.json"), "w+", encoding="utf-8") as f:
f.write(self.json(pr))

write_error_logs(self.attrs, directory)
Expand Down
2 changes: 1 addition & 1 deletion nixpkgs_review/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def list_packages(
% res.returncode
)
tmp.flush()
with open(tmp.name) as f:
with open(tmp.name, encoding="utf-8") as f:
return parse_packages_xml(f)


Expand Down

0 comments on commit e301309

Please sign in to comment.