diff --git a/docs/generate_input_reference.py b/docs/generate_input_reference.py
index 95f50c9bee..80cf3a955c 100755
--- a/docs/generate_input_reference.py
+++ b/docs/generate_input_reference.py
@@ -28,7 +28,7 @@ def main() -> None:
# ======================================================================================
def build_bibliography(references_html_fn: str, output_dir: Path) -> None:
content = Path(references_html_fn).read_text()
- entries = re.findall("
.*?
", content, re.DOTALL)
+ entries = re.findall(r".*?
", content, re.DOTALL)
output = []
output += ["%", "% This file was created by generate_input_reference.py", "%"]
@@ -36,22 +36,22 @@ def build_bibliography(references_html_fn: str, output_dir: Path) -> None:
for entry in entries:
pattern = (
- '| \[(.*?)\] | \n (.*?) '
- "(.*?) |
"
+ r'| \[(.*?)\] | \n (.*?) '
+ r"(.*?) |
"
)
parts = re.search(pattern, entry, re.DOTALL)
assert parts
key = parts.group(1)
title = parts.group(3).strip()
if "
" in parts.group(2):
- m = re.match("(.*?)
(.*)", parts.group(2), re.DOTALL)
+ m = re.match(r"(.*?)
(.*)", parts.group(2), re.DOTALL)
assert m
authors, mix = m.groups()
else:
authors, mix = "", parts.group(2)
if "https://doi.org" in mix:
- m = re.match('\s*(.*?)', mix, re.DOTALL)
+ m = re.match(r'\s*(.*?)', mix, re.DOTALL)
assert m
doi, ref = m.groups()
else:
@@ -367,13 +367,13 @@ def sanitize_name(name: str) -> str:
# ======================================================================================
def escape_markdown(text: str) -> str:
# Code blocks without a language get mistaken for the end of the py:data directive.
- text = text.replace("\n\n```\n", "\n\n```none\n")
+ text = text.replace(r"\n\n```\n", r"\n\n```none\n")
# Underscores are very common in our docs. Luckily asterisks also work for emphasis.
- text = text.replace("__", "\_\_")
+ text = text.replace(r"__", r"\_\_")
# Headings mess up the page structure. Please use paragraphs and bold text instead.
- text = text.replace("#", "\#")
+ text = text.replace(r"#", r"\#")
return text
diff --git a/tools/docker/generate_dockerfiles.py b/tools/docker/generate_dockerfiles.py
index 022ed10de2..a188b670aa 100755
--- a/tools/docker/generate_dockerfiles.py
+++ b/tools/docker/generate_dockerfiles.py
@@ -371,8 +371,8 @@ def install_cp2k(
if revision:
input_lines.append("ARG GIT_COMMIT_SHA")
run_lines.append(
- 'if [ -n "${GIT_COMMIT_SHA}" ] ; then'
- ' echo "git:\${GIT_COMMIT_SHA::7}" > REVISION; fi'
+ r'if [ -n "${GIT_COMMIT_SHA}" ] ; then'
+ r' echo "git:\${GIT_COMMIT_SHA::7}" > REVISION; fi'
)
input_lines.append("COPY ./Makefile .")
diff --git a/tools/precommit/check_file_properties.py b/tools/precommit/check_file_properties.py
index 55108141a5..24a0f488ca 100755
--- a/tools/precommit/check_file_properties.py
+++ b/tools/precommit/check_file_properties.py
@@ -7,7 +7,7 @@ import os
import pathlib
import re
import sys
-from datetime import datetime
+from datetime import datetime, timezone
from functools import lru_cache
import itertools
from typing import Tuple, List, TypeVar
@@ -77,7 +77,7 @@ FLAG_EXCEPTIONS = (
FLAG_EXCEPTIONS_RE = re.compile(r"|".join(FLAG_EXCEPTIONS))
PORTABLE_FILENAME_RE = re.compile(r"^[a-zA-Z0-9._/#~=+-]*$")
OP_RE = re.compile(r"[\\|()!&><=*/+-]")
-NUM_RE = re.compile("[0-9]+[ulUL]*")
+NUM_RE = re.compile(r"[0-9]+[ulUL]*")
CP2K_FLAGS_RE = re.compile(
r"FUNCTION cp2k_flags\(\)(.*)END FUNCTION cp2k_flags", re.DOTALL
)
@@ -183,7 +183,7 @@ def check_file(path: pathlib.Path) -> List[str]:
warnings += [f"{path}:{i+1} Double space in multi-line string"]
# check banner
- year = datetime.utcnow().year
+ year = datetime.now(timezone.utc).year
bsd_licensed = any(str(path).startswith(d) for d in BSD_DIRECTORIES)
spdx = "BSD-3-Clause " if bsd_licensed else "GPL-2.0-or-later"
if fn_ext == ".F" and not content.startswith(BANNER_F.format(year, spdx)):