Skip to content

Commit

Permalink
Merge pull request #75 from cooperlees/master
Browse files Browse the repository at this point in the history
Add mypy to CI for cpython
  • Loading branch information
saghul authored Dec 12, 2019
2 parents 474de1c + 73656e6 commit 680f5ad
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ __pycache__/
.tox/
deps/
docs/_build/

.mypy_cache/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ install:

script:
- ./tests.py
- python mypy_run.py

12 changes: 6 additions & 6 deletions aiodns/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
Any,
List,
Optional,
Set
)

# TODO: Work out mypy no attribute error and remove ignore
from . import error # type: ignore
from . import error


__version__ = '2.0.0'
Expand Down Expand Up @@ -47,7 +47,7 @@ def __init__(self, nameservers=None, loop=None, **kwargs):
self.nameservers = nameservers
self._read_fds = set() # type: Set[int]
self._write_fds = set() # type: Set[int]
self._timer = None
self._timer = None # type: Optional[asyncio.TimerHandle]

@property
def nameservers(self):
Expand Down Expand Up @@ -75,21 +75,21 @@ def query(self, host, qtype):
qtype = query_type_map[qtype]
except KeyError:
raise ValueError('invalid query type: {}'.format(qtype))
fut = asyncio.Future(loop=self.loop)
fut = asyncio.Future(loop=self.loop) # type: asyncio.Future
cb = functools.partial(self._callback, fut)
self._channel.query(host, qtype, cb)
return fut

def gethostbyname(self, host, family):
# type: (str, socket.AddressFamily) -> asyncio.Future
fut = asyncio.Future(loop=self.loop)
fut = asyncio.Future(loop=self.loop) # type: asyncio.Future
cb = functools.partial(self._callback, fut)
self._channel.gethostbyname(host, family, cb)
return fut

def gethostbyaddr(self, name):
# type: (str) -> asyncio.Future
fut = asyncio.Future(loop=self.loop)
fut = asyncio.Future(loop=self.loop) # type: asyncio.Future
cb = functools.partial(self._callback, fut)
self._channel.gethostbyaddr(name, cb)
return fut
Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
ignore_missing_imports = True
16 changes: 16 additions & 0 deletions mypy_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python

from subprocess import run
import sys

# Check if we're not cpython - Exit cleanly if so
if sys.implementation.name != "cpython":
sys.exit(0)

# We only want to install if we're cpython too
install_success = run("pip install mypy", shell=True).returncode
if install_success:
print("mypy install failed", file=sys.stderr)
sys.exit(install_success)

sys.exit(run("mypy aiodns", shell=True).returncode)

0 comments on commit 680f5ad

Please sign in to comment.