aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiroslav Šedivý <[email protected]>2022-12-02 22:04:23 +0100
committerMiroslav Šedivý <[email protected]>2022-12-02 22:04:23 +0100
commit325cc917d5ad14b130b156d23b7adca46499dc24 (patch)
tree247b41199512db9693d00baf7522602805e31c3f /mastodon/utility.py
parentc796cf39b01e38fe381fb4743988da991b072183 (diff)
downloadmastodon.py-325cc917d5ad14b130b156d23b7adca46499dc24.tar.gz
refactor: use f-strings
Diffstat (limited to 'mastodon/utility.py')
-rw-r--r--mastodon/utility.py13
1 files changed, 6 insertions, 7 deletions
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):
39 version = max_version(last_changed_ver, return_value_ver) 39 version = max_version(last_changed_ver, return_value_ver)
40 major, minor, patch = parse_version_string(version) 40 major, minor, patch = parse_version_string(version)
41 if major > self.mastodon_major: 41 if major > self.mastodon_major:
42 raise MastodonVersionError("Version check failed (Need version " + version + ")") 42 raise MastodonVersionError(f"Version check failed (Need version {version})")
43 elif major == self.mastodon_major and minor > self.mastodon_minor: 43 elif major == self.mastodon_major and minor > self.mastodon_minor:
44 raise MastodonVersionError("Version check failed (Need version " + version + ")") 44 raise MastodonVersionError(f"Version check failed (Need version {version})")
45 elif major == self.mastodon_major and minor == self.mastodon_minor and patch > self.mastodon_patch: 45 elif major == self.mastodon_major and minor == self.mastodon_minor and patch > self.mastodon_patch:
46 raise MastodonVersionError("Version check failed (Need version " + version + ", patch is " + str(self.mastodon_patch) + ")") 46 raise MastodonVersionError(f"Version check failed (Need version {version}, patch is {self.mastodon_patch})")
47 return function(self, *args, **kwargs) 47 return function(self, *args, **kwargs)
48 function.__doc__ = function.__doc__ + "\n\n *Added: Mastodon v" + \ 48 function.__doc__ += f"\n\n *Added: Mastodon v{created_ver}, last changed: Mastodon v{last_changed_ver}*"
49 created_ver + ", last changed: Mastodon v" + last_changed_ver + "*"
50 return decorate(function, wrapper) 49 return decorate(function, wrapper)
51 return api_min_version_decorator 50 return api_min_version_decorator
52 51
@@ -59,7 +58,7 @@ class AttribAccessDict(dict):
59 if attr in self: 58 if attr in self:
60 return self[attr] 59 return self[attr]
61 else: 60 else:
62 raise AttributeError("Attribute not found: " + str(attr)) 61 raise AttributeError(f"Attribute not found: {attr}")
63 62
64 def __setattr__(self, attr, val): 63 def __setattr__(self, attr, val):
65 if attr in self: 64 if attr in self:
@@ -76,7 +75,7 @@ class AttribAccessList(list):
76 if attr in self: 75 if attr in self:
77 return self[attr] 76 return self[attr]
78 else: 77 else:
79 raise AttributeError("Attribute not found: " + str(attr)) 78 raise AttributeError(f"Attribute not found: {attr}")
80 79
81 def __setattr__(self, attr, val): 80 def __setattr__(self, attr, val):
82 if attr in self: 81 if attr in self:
Powered by cgit v1.2.3 (git 2.41.0)