Skip to content

Commit 19b57d0

Browse files
committed
fix: direct .format() usage in exception messages
src/tmuxp/_internal/config_reader.py:50:39: EM102 Exception must not use an f-string literal, assign to variable first src/tmuxp/_internal/config_reader.py:113:39: EM102 Exception must not use an f-string literal, assign to variable first src/tmuxp/_internal/config_reader.py:188:39: EM102 Exception must not use an f-string literal, assign to variable first src/tmuxp/plugin.py:191:21: EM103 Exception must not use a `.format()` string directly, assign to variable first Found 4 errors.
1 parent 76c6189 commit 19b57d0

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/tmuxp/_internal/config_reader.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def _load(format: "FormatLiteral", content: str) -> t.Dict[str, t.Any]:
4747
elif format == "json":
4848
return t.cast(t.Dict[str, t.Any], json.loads(content))
4949
else:
50-
raise NotImplementedError(f"{format} not supported in configuration")
50+
msg = f"{format} not supported in configuration"
51+
raise NotImplementedError(msg)
5152

5253
@classmethod
5354
def load(cls, format: "FormatLiteral", content: str) -> "ConfigReader":
@@ -110,7 +111,8 @@ def _from_file(cls, path: pathlib.Path) -> t.Dict[str, t.Any]:
110111
elif path.suffix == ".json":
111112
format = "json"
112113
else:
113-
raise NotImplementedError(f"{path.suffix} not supported in {path}")
114+
msg = f"{path.suffix} not supported in {path}"
115+
raise NotImplementedError(msg)
114116

115117
return cls._load(
116118
format=format,
@@ -185,7 +187,8 @@ def _dump(
185187
indent=2,
186188
)
187189
else:
188-
raise NotImplementedError(f"{format} not supported in config")
190+
msg = f"{format} not supported in config"
191+
raise NotImplementedError(msg)
189192

190193
def dump(self, format: "FormatLiteral", indent: int = 2, **kwargs: t.Any) -> str:
191194
r"""Dump via ConfigReader instance.

src/tmuxp/plugin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,17 @@ def _version_check(self) -> None:
187187
try:
188188
assert self._pass_version_check(**constraints)
189189
except AssertionError as e:
190-
raise TmuxpPluginException(
190+
msg = (
191191
"Incompatible {dep} version: {version}\n{plugin_name} "
192192
"requirements:\nmin: {vmin} | max: {vmax} | "
193193
"incompatible: {incompatible}\n".format(
194194
dep=dep,
195195
plugin_name=self.plugin_name,
196196
**constraints,
197-
),
197+
)
198+
)
199+
raise TmuxpPluginException(
200+
msg,
198201
) from e
199202

200203
def _pass_version_check(

0 commit comments

Comments
 (0)