From 325cc917d5ad14b130b156d23b7adca46499dc24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= <6774676+eumiro@users.noreply.github.com> Date: Fri, 2 Dec 2022 22:04:23 +0100 Subject: refactor: use f-strings --- mastodon/utility.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'mastodon/utility.py') diff --git a/mastodon/utility.py b/mastodon/utility.py index 2510dca..200f5c1 100644 --- a/mastodon/utility.py +++ b/mastodon/utility.py @@ -39,14 +39,13 @@ def api_version(created_ver, last_changed_ver, return_value_ver): version = max_version(last_changed_ver, return_value_ver) major, minor, patch = parse_version_string(version) if major > self.mastodon_major: - raise MastodonVersionError("Version check failed (Need version " + version + ")") + raise MastodonVersionError(f"Version check failed (Need version {version})") elif major == self.mastodon_major and minor > self.mastodon_minor: - raise MastodonVersionError("Version check failed (Need version " + version + ")") + raise MastodonVersionError(f"Version check failed (Need version {version})") elif major == self.mastodon_major and minor == self.mastodon_minor and patch > self.mastodon_patch: - raise MastodonVersionError("Version check failed (Need version " + version + ", patch is " + str(self.mastodon_patch) + ")") + raise MastodonVersionError(f"Version check failed (Need version {version}, patch is {self.mastodon_patch})") return function(self, *args, **kwargs) - function.__doc__ = function.__doc__ + "\n\n *Added: Mastodon v" + \ - created_ver + ", last changed: Mastodon v" + last_changed_ver + "*" + function.__doc__ += f"\n\n *Added: Mastodon v{created_ver}, last changed: Mastodon v{last_changed_ver}*" return decorate(function, wrapper) return api_min_version_decorator @@ -59,7 +58,7 @@ class AttribAccessDict(dict): if attr in self: return self[attr] else: - raise AttributeError("Attribute not found: " + str(attr)) + raise AttributeError(f"Attribute not found: {attr}") def __setattr__(self, attr, val): if attr in self: @@ -76,7 +75,7 @@ class AttribAccessList(list): if attr in self: return self[attr] else: - raise AttributeError("Attribute not found: " + str(attr)) + raise AttributeError(f"Attribute not found: {attr}") def __setattr__(self, attr, val): if attr in self: -- cgit v1.2.3