Enable flake8-errmsg linting rules (#267)

See https://docs.astral.sh/ruff/rules/#flake8-errmsg-em.
This commit is contained in:
Marc Wrobel
2023-12-30 11:26:28 +01:00
parent fb7c4f6bcc
commit 298ad1a754
4 changed files with 7 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ select = [
"COM", # flake8-commas
"DTZ", # flake8-commas
"E", # pycodestyle errors
"EM", # pycodestyle errors
"F", # pyflakes errors
"I", # isort
"ISC", # flake8-implicit-str-concat

View File

@@ -50,7 +50,8 @@ def parse_datetime(text: str, formats: list[str] = frozenset([
except ValueError:
pass
raise ValueError(f"'{text}' could not be parsed as a date with any of the formats: {str(formats)}")
msg = f"'{text}' could not be parsed as a date with any of the formats: {str(formats)}"
raise ValueError(msg)
def date(year: int, month: int, day: int) -> datetime:

View File

@@ -114,7 +114,8 @@ class Product:
def replace_version(self, version: str, date: datetime) -> None:
if version not in self.versions:
raise ValueError(f"version {version} cannot be replaced as it does not exist for {self.name}")
msg = f"version {version} cannot be replaced as it does not exist for {self.name}"
raise ValueError(msg)
logging.info(f"replacing version {version} ({self.versions[version]} -> {date}) in {self.name}")
self.versions[version] = date

View File

@@ -20,7 +20,8 @@ class Git:
child = run(f"git {cmd}", capture_output=True, timeout=300, check=True, shell=True, cwd=self.repo_dir)
return child.stdout.decode("utf-8").strip().split("\n")
except ChildProcessError as ex:
raise RuntimeError(f"Failed to run '{cmd}': {ex}") from ex
msg = f"Failed to run '{cmd}': {ex}"
raise RuntimeError(msg) from ex
def setup(self, bare: bool = False) -> None:
"""Creates the repository path and runs: