Skip to content

Commit

Permalink
Add mypy to TravisCI Run
Browse files Browse the repository at this point in the history
- Also fix all type errors with latest mypy
- pycares seems to have no typing / stubs so lets ignore it via `mypy.ini`
  • Loading branch information
cooperlees committed Dec 12, 2019
1 parent 474de1c commit 0038a36
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 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/
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ branches:
- master

before_install:
- pip install -U setuptools pip wheel
- pip install -U setuptools pip mypy wheel

install:
- python -V
- pip install .

script:
- ./tests.py
- mypy aiodns

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

0 comments on commit 0038a36

Please sign in to comment.