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 drop python<=3.7 support #608

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
version_file = os.path.join(os.path.dirname(os.path.dirname(__file__)),
'uvloop', '_version.py')

with open(version_file, 'r') as f:
with open(version_file) as f:
for line in f:
if line.startswith('__version__ ='):
_, _, version = line.partition('=')
Expand Down
2 changes: 1 addition & 1 deletion examples/bench/echoclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
addr = args.addr.split(':')
addr[1] = int(addr[1])
addr = tuple(addr)
print('will connect to: {}'.format(addr))
print(f'will connect to: {addr}')

MSGSIZE = args.msize
REQSIZE = MSGSIZE * args.mpr
Expand Down
2 changes: 1 addition & 1 deletion examples/bench/echoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async def print_debug(loop):
addr[1] = int(addr[1])
addr = tuple(addr)

print('serving on: {}'.format(addr))
print(f'serving on: {addr}')

server_context = None
if args.ssl:
Expand Down
2 changes: 1 addition & 1 deletion examples/bench/rlserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def print_debug(loop):
addr = tuple(addr)

print('readline performance test')
print('serving on: {}'.format(addr))
print(f'serving on: {addr}')

print('using asyncio/streams')
if unix:
Expand Down
8 changes: 2 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import sys

vi = sys.version_info
if vi < (3, 8):
raise RuntimeError('uvloop requires Python 3.8 or greater')

Comment on lines -3 to -6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"requires-python = '>=3.8.0'" in pyproject.toml is enough.

I'd keep this extra check. For people who uses Python < 3.8, they may also have a pip around year 2016 or earlier, which doesn't honor requires-python.

if sys.platform in ('win32', 'cygwin', 'cli'):
raise RuntimeError('uvloop does not support Windows at the moment')

Expand All @@ -26,7 +22,7 @@
MODULES_CFLAGS = [os.getenv('UVLOOP_OPT_CFLAGS', '-O2')]
_ROOT = pathlib.Path(__file__).parent
LIBUV_DIR = str(_ROOT / 'vendor' / 'libuv')
LIBUV_BUILD_DIR = str(_ROOT / 'build' / 'libuv-{}'.format(MACHINE))
LIBUV_BUILD_DIR = str(_ROOT / 'build' / f'libuv-{MACHINE}')


def _libuv_build_env():
Expand Down Expand Up @@ -176,7 +172,7 @@ def build_libuv(self):
cmd,
cwd=LIBUV_BUILD_DIR, env=env, check=True)

j_flag = '-j{}'.format(os.cpu_count() or 1)
j_flag = f'-j{os.cpu_count() or 1}'
c_flag = "CFLAGS={}".format(env['CFLAGS'])
subprocess.run(
['make', j_flag, c_flag],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def on_shutdown(app):
async def client():
async with aiohttp.ClientSession() as client:
async with client.ws_connect(
'http://127.0.0.1:{}'.format(port)) as ws:
f'http://127.0.0.1:{port}') as ws:
await ws.send_str("hello")
async for msg in ws:
assert msg.data == "hello"
Expand Down
8 changes: 4 additions & 4 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ def fut_on_done(fut):
for j in range(2):
fut = self.loop.create_future()
fut.add_done_callback(fut_on_done)
cvar.set('yes{}'.format(j))
cvar.set(f'yes{j}')
self.loop.call_soon(fut.set_result, None)
await fut
self.assertEqual(cvar.get(), 'yes{}'.format(j))
self.assertEqual(cvar.get(), f'yes{j}')

for i in range(3):
# Test that task passed its context to add_done_callback:
cvar.set('yes{}-{}'.format(i, j))
cvar.set(f'yes{i}-{j}')
await asyncio.sleep(0.001)
self.assertEqual(cvar.get(), 'yes{}-{}'.format(i, j))
self.assertEqual(cvar.get(), f'yes{i}-{j}')

task = self.loop.create_task(main())
self.loop.run_until_complete(task)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_getaddrinfo_close_loop(self):
try:
# Check that we have internet connection
socket.getaddrinfo('example.com', 80)
except socket.error:
except OSError:
raise unittest.SkipTest

async def run():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fs_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def run(write_task):

with tempfile.TemporaryDirectory() as td_name:
self.dname = td_name
f = open(os.path.join(td_name, self.changed_name), 'wt')
f = open(os.path.join(td_name, self.changed_name), 'w')
f.write('hello!')
f.close()
h = self.loop._monitor_fs(td_name, self.event_cb)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_pipes.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import io now

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_read_pipe(self):
proto = MyReadPipeProto(loop=self.loop)

rpipe, wpipe = os.pipe()
pipeobj = io.open(rpipe, 'rb', 1024)
pipeobj = open(rpipe, 'rb', 1024)

async def connect():
t, p = await self.loop.connect_read_pipe(
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_read_pty_output(self):
proto = MyReadPipeProto(loop=self.loop)

master, slave = os.openpty()
master_read_obj = io.open(master, 'rb', 0)
master_read_obj = open(master, 'rb', 0)

async def connect():
t, p = await self.loop.connect_read_pipe(
Expand Down Expand Up @@ -142,7 +142,7 @@ async def connect():
def test_write_pipe(self):
rpipe, wpipe = os.pipe()
os.set_blocking(rpipe, False)
pipeobj = io.open(wpipe, 'wb', 1024)
pipeobj = open(wpipe, 'wb', 1024)

proto = MyWritePipeProto(loop=self.loop)
connect = self.loop.connect_write_pipe(lambda: proto, pipeobj)
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_write_pipe_disconnect_on_close(self):
rsock, wsock = socket.socketpair()
rsock.setblocking(False)

pipeobj = io.open(wsock.detach(), 'wb', 1024)
pipeobj = open(wsock.detach(), 'wb', 1024)

proto = MyWritePipeProto(loop=self.loop)
connect = self.loop.connect_write_pipe(lambda: proto, pipeobj)
Expand All @@ -207,7 +207,7 @@ def test_write_pty(self):
master, slave = os.openpty()
os.set_blocking(master, False)

slave_write_obj = io.open(slave, 'wb', 0)
slave_write_obj = open(slave, 'wb', 0)

proto = MyWritePipeProto(loop=self.loop)
connect = self.loop.connect_write_pipe(lambda: proto, slave_write_obj)
Expand Down Expand Up @@ -250,7 +250,7 @@ def reader(data):

def test_write_buffer_full(self):
rpipe, wpipe = os.pipe()
pipeobj = io.open(wpipe, 'wb', 1024)
pipeobj = open(wpipe, 'wb', 1024)

proto = MyWritePipeProto(loop=self.loop)
connect = self.loop.connect_write_pipe(lambda: proto, pipeobj)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async def test():
stdout=subprocess.PIPE)

pid = proc.pid
expected_result = '{}\n'.format(pid).encode()
expected_result = f'{pid}\n'.encode()

out, err = await proc.communicate()
self.assertEqual(out, expected_result)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_process_spawning.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def spawn_external_process(loop, event):
BufferType = ctypes.c_char * (BUFFER_LENGTH - 1)

def run_echo(popen, fread, pclose):
fd = popen('echo test'.encode('ASCII'), 'r'.encode('ASCII'))
fd = popen(b'echo test', b'r')
try:
while True:
buffer = BufferType()
Expand Down
10 changes: 4 additions & 6 deletions tests/test_sourcecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ def test_flake8(self):
subprocess.run(
[sys.executable, '-m', 'flake8', '--config', config_path],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
capture_output=True,
cwd=os.path.join(edgepath, subdir))
except subprocess.CalledProcessError as ex:
output = ex.stdout.decode()
output += '\n'
output += ex.stderr.decode()
raise AssertionError(
'flake8 validation failed: {}\n{}'.format(ex, output)
f'flake8 validation failed: {ex}\n{output}'
) from None

def test_mypy(self):
Expand All @@ -59,14 +58,13 @@ def test_mypy(self):
'uvloop'
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
capture_output=True,
cwd=edgepath
)
except subprocess.CalledProcessError as ex:
output = ex.stdout.decode()
output += '\n'
output += ex.stderr.decode()
raise AssertionError(
'mypy validation failed: {}\n{}'.format(ex, output)
f'mypy validation failed: {ex}\n{output}'
) from None
2 changes: 1 addition & 1 deletion tests/test_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2806,7 +2806,7 @@ async def test():
except AssertionError as e:
self.assertEqual(str(e), 'ResourceWarning not triggered')
else:
self.fail('Unexpected ResourceWarning: {}'.format(cm.warning))
self.fail(f'Unexpected ResourceWarning: {cm.warning}')

def test_handshake_timeout_handler_leak(self):
if self.implementation == 'asyncio':
Expand Down
2 changes: 1 addition & 1 deletion tests/test_unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def start_server_sock(start_server):
def test_create_unix_server_2(self):
with tempfile.TemporaryDirectory() as td:
sock_name = os.path.join(td, 'sock')
with open(sock_name, 'wt') as f:
with open(sock_name, 'w') as f:
f.write('x')

with self.assertRaisesRegex(
Expand Down
2 changes: 1 addition & 1 deletion uvloop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def wrapper():

if not __asyncio.iscoroutine(main):
raise ValueError(
"a coroutine was expected, got {!r}".format(main)
f"a coroutine was expected, got {main!r}"
)

loop = loop_factory()
Expand Down
8 changes: 4 additions & 4 deletions uvloop/_testbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ def tearDown(self):
handle_name=h_name):
self.assertEqual(
h_cnt, 0,
'alive {} after test'.format(h_name))
f'alive {h_name} after test')

for h_name, h_cnt in self.loop._debug_handles_total.items():
with self.subTest('Total/closed handles',
handle_name=h_name):
self.assertEqual(
h_cnt, self.loop._debug_handles_closed[h_name],
'total != closed for {}'.format(h_name))
f'total != closed for {h_name}')

asyncio.set_event_loop(None)
asyncio.set_event_loop_policy(None)
Expand Down Expand Up @@ -259,7 +259,7 @@ def find_free_port(start_from=50000):
with sock:
try:
sock.bind(('', port))
except socket.error:
except OSError:
continue
else:
return port
Expand Down Expand Up @@ -386,7 +386,7 @@ def __getattr__(self, name):
return getattr(self.__sock, name)

def __repr__(self):
return '<{} {!r}>'.format(type(self).__name__, self.__sock)
return f'<{type(self).__name__} {self.__sock!r}>'


class SocketThread(threading.Thread):
Expand Down
Loading