Skip to content

Commit db642bb

Browse files
Upgrade the code to more recent Python versions
1 parent bf5a05a commit db642bb

20 files changed

+22
-25
lines changed

examples/client/async/latency_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def connect():
2323
async def pong_from_server():
2424
global start_timer
2525
latency = time.time() - start_timer
26-
print('latency is {0:.2f} ms'.format(latency * 1000))
26+
print(f'latency is {latency * 1000:.2f} ms')
2727
await sio.sleep(1)
2828
if sio.connected:
2929
await send_ping()

examples/client/sync/latency_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def connect():
2121
def pong_from_server():
2222
global start_timer
2323
latency = time.time() - start_timer
24-
print('latency is {0:.2f} ms'.format(latency * 1000))
24+
print(f'latency is {latency * 1000:.2f} ms')
2525
sio.sleep(1)
2626
if sio.connected:
2727
send_ping()

examples/simple-client/async/latency_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async def main():
1212
while (await sio.receive()) != ['pong_from_server']:
1313
pass
1414
latency = time.time() - start_timer
15-
print('latency is {0:.2f} ms'.format(latency * 1000))
15+
print(f'latency is {latency * 1000:.2f} ms')
1616

1717
await asyncio.sleep(1)
1818

examples/simple-client/sync/latency_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def main():
1111
while sio.receive() != ['pong_from_server']:
1212
pass
1313
latency = time.time() - start_timer
14-
print('latency is {0:.2f} ms'.format(latency * 1000))
14+
print(f'latency is {latency * 1000:.2f} ms')
1515

1616
time.sleep(1)
1717

src/socketio/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self):
1616

1717
def push(self, type, count=1):
1818
timestamp = int(time.time()) * 1000
19-
key = '{};{}'.format(timestamp, type)
19+
key = f'{timestamp};{type}'
2020
if key not in self.buffer:
2121
self.buffer[key] = {
2222
'timestamp': timestamp,

src/socketio/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ async def _send_packet(self, pkt):
386386
async def _handle_connect(self, namespace, data):
387387
namespace = namespace or '/'
388388
if namespace not in self.namespaces:
389-
self.logger.info('Namespace {} is connected'.format(namespace))
389+
self.logger.info(f'Namespace {namespace} is connected')
390390
self.namespaces[namespace] = (data or {}).get('sid', self.sid)
391391
await self._trigger_event('connect', namespace=namespace)
392392
self._connect_event.set()

src/socketio/async_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def on_message(sid, msg):
385385
async with eio.session(sid) as session:
386386
print('received message from ', session['username'])
387387
"""
388-
class _session_context_manager(object):
388+
class _session_context_manager:
389389
def __init__(self, server, sid, namespace):
390390
self.server = server
391391
self.sid = sid

src/socketio/base_manager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def get_participants(self, namespace, room):
3737
participants.update(ns[r]._fwdm if r in ns else {})
3838
else:
3939
participants = ns[room]._fwdm.copy() if room in ns else {}
40-
for sid, eio_sid in participants.items():
41-
yield sid, eio_sid
40+
yield from participants.items()
4241

4342
def connect(self, eio_sid, namespace):
4443
"""Register a client connection to a namespace."""

src/socketio/base_namespace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class BaseNamespace(object):
1+
class BaseNamespace:
22
def __init__(self, namespace=None):
33
self.namespace = namespace or '/'
44

src/socketio/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def _send_packet(self, pkt):
363363
def _handle_connect(self, namespace, data):
364364
namespace = namespace or '/'
365365
if namespace not in self.namespaces:
366-
self.logger.info('Namespace {} is connected'.format(namespace))
366+
self.logger.info(f'Namespace {namespace} is connected')
367367
self.namespaces[namespace] = (data or {}).get('sid', self.sid)
368368
self._trigger_event('connect', namespace=namespace)
369369
self._connect_event.set()

0 commit comments

Comments
 (0)