Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

really from python<=3.7 support #1313

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
Expand Down
2 changes: 1 addition & 1 deletion examples/client/async/latency_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def connect():
async def pong_from_server():
global start_timer
latency = time.time() - start_timer
print('latency is {0:.2f} ms'.format(latency * 1000))
print(f'latency is {latency * 1000:.2f} ms')
await sio.sleep(1)
if sio.connected:
await send_ping()
Expand Down
2 changes: 1 addition & 1 deletion examples/client/sync/latency_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def connect():
def pong_from_server():
global start_timer
latency = time.time() - start_timer
print('latency is {0:.2f} ms'.format(latency * 1000))
print(f'latency is {latency * 1000:.2f} ms')
sio.sleep(1)
if sio.connected:
send_ping()
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-client/async/latency_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async def main():
while (await sio.receive()) != ['pong_from_server']:
pass
latency = time.time() - start_timer
print('latency is {0:.2f} ms'.format(latency * 1000))
print(f'latency is {latency * 1000:.2f} ms')

await asyncio.sleep(1)

Expand Down
2 changes: 1 addition & 1 deletion examples/simple-client/sync/latency_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def main():
while sio.receive() != ['pong_from_server']:
pass
latency = time.time() - start_timer
print('latency is {0:.2f} ms'.format(latency * 1000))
print(f'latency is {latency * 1000:.2f} ms')

time.sleep(1)

Expand Down
2 changes: 1 addition & 1 deletion src/socketio/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):

def push(self, type, count=1):
timestamp = int(time.time()) * 1000
key = '{};{}'.format(timestamp, type)
key = f'{timestamp};{type}'
if key not in self.buffer:
self.buffer[key] = {
'timestamp': timestamp,
Expand Down
2 changes: 1 addition & 1 deletion src/socketio/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ async def _send_packet(self, pkt):
async def _handle_connect(self, namespace, data):
namespace = namespace or '/'
if namespace not in self.namespaces:
self.logger.info('Namespace {} is connected'.format(namespace))
self.logger.info(f'Namespace {namespace} is connected')
self.namespaces[namespace] = (data or {}).get('sid', self.sid)
await self._trigger_event('connect', namespace=namespace)
self._connect_event.set()
Expand Down
2 changes: 1 addition & 1 deletion src/socketio/async_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def on_message(sid, msg):
async with eio.session(sid) as session:
print('received message from ', session['username'])
"""
class _session_context_manager(object):
class _session_context_manager:
def __init__(self, server, sid, namespace):
self.server = server
self.sid = sid
Expand Down
3 changes: 1 addition & 2 deletions src/socketio/base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def get_participants(self, namespace, room):
participants.update(ns[r]._fwdm if r in ns else {})
else:
participants = ns[room]._fwdm.copy() if room in ns else {}
for sid, eio_sid in participants.items():
yield sid, eio_sid
yield from participants.items()

def connect(self, eio_sid, namespace):
"""Register a client connection to a namespace."""
Expand Down
2 changes: 1 addition & 1 deletion src/socketio/base_namespace.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BaseNamespace(object):
class BaseNamespace:
def __init__(self, namespace=None):
self.namespace = namespace or '/'

Expand Down
2 changes: 1 addition & 1 deletion src/socketio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def _send_packet(self, pkt):
def _handle_connect(self, namespace, data):
namespace = namespace or '/'
if namespace not in self.namespaces:
self.logger.info('Namespace {} is connected'.format(namespace))
self.logger.info(f'Namespace {namespace} is connected')
self.namespaces[namespace] = (data or {}).get('sid', self.sid)
self._trigger_event('connect', namespace=namespace)
self._connect_event.set()
Expand Down
3 changes: 1 addition & 2 deletions src/socketio/kafka_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def _publish(self, data):
self.producer.flush()

def _kafka_listen(self):
for message in self.consumer:
yield message
yield from self.consumer

def _listen(self):
for message in self._kafka_listen():
Expand Down
2 changes: 1 addition & 1 deletion src/socketio/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'BINARY_EVENT', 'BINARY_ACK']


class Packet(object):
class Packet:
"""Socket.IO packet."""

# the format of the Socket.IO packet is as follows:
Expand Down
3 changes: 1 addition & 2 deletions src/socketio/redis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def _redis_listen_with_retries(self):
self._redis_connect()
self.pubsub.subscribe(self.channel)
retry_sleep = 1
for message in self.pubsub.listen():
yield message
yield from self.pubsub.listen()
except redis.exceptions.RedisError:
logger.error('Cannot receive from redis... '
'retrying in {} secs'.format(retry_sleep))
Expand Down
2 changes: 1 addition & 1 deletion src/socketio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def on_message(sid, msg):
with sio.session(sid) as session:
print('received message from ', session['username'])
"""
class _session_context_manager(object):
class _session_context_manager:
def __init__(self, server, sid, namespace):
self.server = server
self.sid = sid
Expand Down
2 changes: 1 addition & 1 deletion src/socketio/zmq_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, url='zmq+tcp://localhost:5555+5556',
sink.connect(sink_url)

sub = zmq.Context().socket(zmq.SUB)
sub.setsockopt_string(zmq.SUBSCRIBE, u'')
sub.setsockopt_string(zmq.SUBSCRIBE, '')
sub.connect(sub_url)

self.sink = sink
Expand Down
2 changes: 1 addition & 1 deletion tests/async/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def test_emit_binary(self):
sid = _run(self.bm.connect('123', '/'))
_run(
self.bm.emit(
u'my event', b'my binary data', namespace='/', room=sid
'my event', b'my binary data', namespace='/', room=sid
)
)
assert self.bm.server._send_eio_packet.mock.call_count == 2
Expand Down
4 changes: 2 additions & 2 deletions tests/async/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ async def on_baz(self, ns, sid, data1, data2):
assert result['result'] == ('disconnect', '1', '/foo')

def test_bad_namespace_handler(self, eio):
class Dummy(object):
class Dummy:
pass

class SyncNS(namespace.Namespace):
Expand Down Expand Up @@ -1007,7 +1007,7 @@ def test_custom_json(self, eio):
# Warning: this test cannot run in parallel with other tests, as it
# changes the JSON encoding/decoding functions

class CustomJSON(object):
class CustomJSON:
@staticmethod
def dumps(*args, **kwargs):
return '*** encoded ***'
Expand Down
2 changes: 1 addition & 1 deletion tests/common/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class MyNamespace(namespace.ClientNamespace):
assert c.namespace_handlers['/foo'] == n

def test_namespace_handler_wrong_class(self):
class MyNamespace(object):
class MyNamespace:
def __init__(self, n):
pass

Expand Down
2 changes: 1 addition & 1 deletion tests/common/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def test_emit_with_none(self):

def test_emit_binary(self):
sid = self.bm.connect('123', '/')
self.bm.emit(u'my event', b'my binary data', namespace='/', room=sid)
self.bm.emit('my event', b'my binary data', namespace='/', room=sid)
assert self.bm.server._send_eio_packet.call_count == 2
assert self.bm.server._send_eio_packet.call_args_list[0][0][0] == '123'
pkt = self.bm.server._send_eio_packet.call_args_list[0][0][1]
Expand Down
4 changes: 2 additions & 2 deletions tests/common/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ def on_baz(self, ns, sid, data1, data2):
assert result['result'] == ('disconnect', '1', '/foo')

def test_bad_namespace_handler(self, eio):
class Dummy(object):
class Dummy:
pass

class AsyncNS(namespace.Namespace):
Expand Down Expand Up @@ -939,7 +939,7 @@ def test_custom_json(self, eio):
# Warning: this test cannot run in parallel with other tests, as it
# changes the JSON encoding/decoding functions

class CustomJSON(object):
class CustomJSON:
@staticmethod
def dumps(*args, **kwargs):
return '*** encoded ***'
Expand Down
Loading