Skip to content

Commit da75623

Browse files
committed
refactor: f string gtid.py
1 parent 7c9bbda commit da75623

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pymysqlreplication/gtid.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,14 @@ def decode(cls, payload):
284284
start, end = struct.unpack("<QQ", payload.read(16))
285285
intervals.append((start, end - 1))
286286

287-
temp = ":".join(
288-
["%d-%d" % x if isinstance(x, tuple) else "%d" % x for x in intervals]
289-
)
287+
def format_interval(x):
288+
if isinstance(x, tuple):
289+
return f"{x[0]}-{x[1]}"
290+
return f"{x}"
291+
292+
intervals_string = ":".join([format_interval(x) for x in intervals])
290293

291-
return cls(f"{sid.decode('ascii')}:{temp}")
294+
return cls(f"{sid.decode('ascii')}:{intervals_string}")
292295

293296
def __eq__(self, other):
294297
if other.sid != self.sid:

0 commit comments

Comments
 (0)