Skip to content

Commit

Permalink
Drop old python (#288)
Browse files Browse the repository at this point in the history
* cleanup

* flake8

* more cleanup

* tweak travis config

* move tests
  • Loading branch information
jettify authored May 1, 2018
1 parent 3041c67 commit 5b20a8a
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python

python:
- 3.5
- 3.5.3
- 3.6

env:
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ FLAGS=


flake:
exclude=$$(python -c "import sys;sys.stdout.write('--exclude tests/pep492') if sys.version_info[:3] < (3, 5, 0) else None"); \
flake8 aiomysql tests $$exclude
flake8 aiomysql tests examples

test: flake
py.test -s $(FLAGS) ./tests/
Expand Down
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ for aiopg_ user.:
Requirements
------------

* Python_ 3.3+
* asyncio_ or Python_ 3.4+
* Python_ 3.5.3+
* PyMySQL_


Expand Down
5 changes: 2 additions & 3 deletions aiomysql/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@

# from aiomysql.utils import _convert_to_str
from .cursors import Cursor
from .utils import (_ConnectionContextManager, _ContextManager,
create_future)
from .utils import _ConnectionContextManager, _ContextManager
# from .log import logger

DEFAULT_USER = getpass.getuser()
Expand Down Expand Up @@ -384,7 +383,7 @@ def cursor(self, cursor=None):
cur = cursor(self, self._echo)
else:
cur = self.cursorclass(self, self._echo)
fut = create_future(self._loop)
fut = self._loop.create_future()
fut.set_result(cur)
return _ContextManager(fut)

Expand Down
11 changes: 5 additions & 6 deletions aiomysql/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
NotSupportedError, ProgrammingError)

from .log import logger
from .utils import create_future


# https://github.com/PyMySQL/PyMySQL/blob/master/pymysql/cursors.py#L11-L18
Expand Down Expand Up @@ -362,15 +361,15 @@ async def callproc(self, procname, args=()):
def fetchone(self):
"""Fetch the next row """
self._check_executed()
fut = create_future(self._loop)
fut = self._loop.create_future()

if self._rows is None or self._rownumber >= len(self._rows):
fut.set_result(None)
return fut
result = self._rows[self._rownumber]
self._rownumber += 1

fut = create_future(self._loop)
fut = self._loop.create_future()
fut.set_result(result)
return fut

Expand All @@ -386,7 +385,7 @@ def fetchmany(self, size=None):
:returns: ``list`` of fetched rows
"""
self._check_executed()
fut = create_future(self._loop)
fut = self._loop.create_future()
if self._rows is None:
fut.set_result([])
return fut
Expand All @@ -403,7 +402,7 @@ def fetchall(self):
:returns: ``list`` of fetched rows
"""
self._check_executed()
fut = create_future(self._loop)
fut = self._loop.create_future()
if self._rows is None:
fut.set_result([])
return fut
Expand Down Expand Up @@ -443,7 +442,7 @@ def scroll(self, value, mode='relative'):
raise IndexError("out of range")
self._rownumber = r

fut = create_future(self._loop)
fut = self._loop.create_future()
fut.set_result(None)
return fut

Expand Down
6 changes: 3 additions & 3 deletions aiomysql/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from .connection import connect
from .utils import (_PoolContextManager, _PoolConnectionContextManager,
_PoolAcquireContextManager, create_future, create_task)
_PoolAcquireContextManager)


def create_pool(minsize=1, maxsize=10, echo=False, pool_recycle=-1,
Expand Down Expand Up @@ -194,7 +194,7 @@ def release(self, conn):
This is **NOT** a coroutine.
"""
fut = create_future(self._loop)
fut = self._loop.create_future()
fut.set_result(None)

if conn in self._terminated:
Expand All @@ -212,7 +212,7 @@ def release(self, conn):
conn.close()
else:
self._free.append(conn)
fut = create_task(self._wakeup(), self._loop)
fut = self._loop.create_task(self._wakeup())
return fut

def get(self):
Expand Down
3 changes: 1 addition & 2 deletions aiomysql/sa/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from sqlalchemy.sql import expression, sqltypes

from . import exc
from ..utils import create_task


async def create_result_proxy(connection, cursor, dialect):
Expand Down Expand Up @@ -239,7 +238,7 @@ async def _prepare(self):
self._metadata = ResultMetaData(self, cursor.description)

def callback(wr):
create_task(cursor.close(), loop)
loop.create_task(cursor.close())
self._weak = weakref.ref(self, callback)
else:
self._metadata = None
Expand Down
26 changes: 0 additions & 26 deletions aiomysql/utils.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
import asyncio

from collections.abc import Coroutine


def create_future(loop):
"""Compatibility wrapper for the loop.create_future() call introduced in
3.5.2."""
if hasattr(loop, 'create_future'):
return loop.create_future()
else:
return asyncio.Future(loop=loop)


def create_task(coro, loop):
"""Compatibility wrapper for the loop.create_task() call introduced in
3.4.2."""
if hasattr(loop, 'create_task'):
return loop.create_task(coro)
else:
return asyncio.Task(coro, loop=loop)


class _ContextManager(Coroutine):

__slots__ = ('_coro', '_obj')
Expand Down Expand Up @@ -169,9 +149,3 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
finally:
self._pool = None
self._conn = None


try:
asyncio.coroutines._COROUTINE_TYPES += (_ContextManager,)
except Exception:
pass
1 change: 1 addition & 0 deletions examples/example_executemany_oldstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ def test_example_executemany():
yield from cur.close()
conn.close()


loop.run_until_complete(test_example_executemany())
1 change: 1 addition & 0 deletions examples/example_oldstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ def test_example():
yield from cur.close()
conn.close()


loop.run_until_complete(test_example())
1 change: 1 addition & 0 deletions examples/example_pool_oldstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ def test_example():
pool.close()
yield from pool.wait_closed()


loop.run_until_complete(test_example())
1 change: 1 addition & 0 deletions examples/example_transaction_oldstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ def test_example_transaction():
yield from cursor.close()
conn.close()


loop.run_until_complete(test_example_transaction())
14 changes: 5 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@

PY_VER = sys.version_info

if PY_VER >= (3, 4):
pass
elif PY_VER >= (3, 3):
install_requires.append('asyncio')
else:
raise RuntimeError("aiomysql doesn't suppport Python earllier than 3.3")

if not PY_VER >= (3, 5, 3):
raise RuntimeError("aiomysql doesn't support Python earlier than 3.5.3")


def read(f):
return open(os.path.join(os.path.dirname(__file__), f)).read().strip()


extras_require = {'sa': ['sqlalchemy>=0.9'], }
extras_require = {'sa': ['sqlalchemy>=1.0'], }


def read_version():
Expand All @@ -40,9 +37,8 @@ def read_version():
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Operating System :: POSIX',
'Environment :: Web Environment',
'Development Status :: 3 - Alpha',
Expand Down
Empty file removed tests/pep492/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.

0 comments on commit 5b20a8a

Please sign in to comment.