Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit f749764

Browse files
authored
tests: add basic type checking with mypy (#756)
Closes #736
1 parent 71426a6 commit f749764

File tree

6 files changed

+27
-4
lines changed

6 files changed

+27
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ build/
77
mock*/
88
nose*/
99
.pybuild/
10+
.mypy_cache/
1011
debian/files
1112
debian/python-influxdb.debhelper.log
1213
debian/python-influxdb.postinst.debhelper

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ matrix:
3131
env: TOX_ENV=flake8
3232
- python: 3.7
3333
env: TOX_ENV=coverage
34+
- python: 3.7
35+
env: TOX_ENV=mypy
3436

3537
install:
3638
- pip install tox-travis

influxdb/dataframe_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ def __init__(self, *a, **kw):
2525
raise ImportError("DataFrameClient requires Pandas "
2626
"which couldn't be imported: %s" % self.err)
2727
else:
28-
from ._dataframe_client import DataFrameClient
28+
from ._dataframe_client import DataFrameClient # type: ignore

influxdb/tests/server_tests/base.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,15 @@ class SingleTestCaseWithServerMixin(object):
5151
# 'influxdb_template_conf' attribute must be set
5252
# on the TestCase class or instance.
5353

54-
setUp = _setup_influxdb_server
55-
tearDown = _teardown_influxdb_server
54+
@classmethod
55+
def setUp(cls):
56+
"""Set up an instance of the SingleTestCaseWithServerMixin."""
57+
_setup_influxdb_server(cls)
58+
59+
@classmethod
60+
def tearDown(cls):
61+
"""Tear down an instance of the SingleTestCaseWithServerMixin."""
62+
_teardown_influxdb_server(cls)
5663

5764

5865
class ManyTestCasesWithServerMixin(object):

mypy.ini

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[mypy]
2+
ignore_missing_imports = True
3+
warn_unused_ignores = True
4+
warn_unused_configs = True
5+
warn_redundant_casts = True
6+
warn_no_return = True
7+
no_implicit_optional = True
8+
strict_equality = True

tox.ini

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27, py35, py36, py37, pypy, pypy3, flake8, pep257, coverage, docs
2+
envlist = py27, py35, py36, py37, pypy, pypy3, flake8, pep257, coverage, docs, mypy
33

44
[testenv]
55
passenv = INFLUXDB_PYTHON_INFLUXD_PATH
@@ -44,6 +44,11 @@ deps = -r{toxinidir}/requirements.txt
4444
sphinx_rtd_theme
4545
commands = sphinx-build -b html docs/source docs/build
4646

47+
[testenv:mypy]
48+
deps = -r{toxinidir}/test-requirements.txt
49+
mypy==0.720
50+
commands = mypy --config-file mypy.ini -p influxdb
51+
4752
[flake8]
4853
ignore = W503,W504,W605,N802,F821,E402
4954
# W503: Line break occurred before a binary operator

0 commit comments

Comments
 (0)