From 43312ef8ac8b2af8afb38b8334f10c751f770b47 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:52:35 +0100 Subject: [PATCH] Enable the PLW1514 lint in Ruff --- .ruff.toml | 1 - sphinx/cmd/make_mode.py | 2 +- sphinx/util/exceptions.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index 4dca3d16c..64ba850a4 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -57,7 +57,6 @@ ignore = [ "PLR6201", # Use a set literal when testing for membership "PLR6301", # Method `{method_name}` could be a function, class method, or static method # pylint ('PLW') - "PLW1514", # `{function_name}` in text mode without explicit `encoding` argument "PLW1641", # Object does not implement `__hash__` method "PLW2901", # Outer {outer_kind} variable `{name}` overwritten by inner {inner_kind} target "PLW3201", # Dunder method `{name}` has no special meaning in Python 3 diff --git a/sphinx/cmd/make_mode.py b/sphinx/cmd/make_mode.py index af180a926..ac22ba998 100644 --- a/sphinx/cmd/make_mode.py +++ b/sphinx/cmd/make_mode.py @@ -106,7 +106,7 @@ class Make: try: with chdir(self.build_dir_join('latex')): if '-Q' in self.opts: - with open('__LATEXSTDOUT__', 'w') as outfile: + with open('__LATEXSTDOUT__', 'w', encoding='utf-8') as outfile: returncode = subprocess.call( [ makecmd, diff --git a/sphinx/util/exceptions.py b/sphinx/util/exceptions.py index a0403c384..f12732558 100644 --- a/sphinx/util/exceptions.py +++ b/sphinx/util/exceptions.py @@ -41,7 +41,7 @@ def save_traceback(app: Sphinx | None, exc: BaseException) -> str: ) with NamedTemporaryFile( - 'w', suffix='.log', prefix='sphinx-err-', delete=False + 'w', encoding='utf-8', suffix='.log', prefix='sphinx-err-', delete=False ) as f: f.write(f"""\ # Platform: {sys.platform}; ({platform.platform()})