Merge pull request #86 from python-hyper/travis-lint
Add flake8 and mypy to Travis
This commit is contained in:
commit
eb8bc0812d
|
@ -5,6 +5,10 @@ language: python
|
|||
|
||||
matrix:
|
||||
include:
|
||||
- python: "3.8"
|
||||
env: TOXENV=flake8
|
||||
- python: "3.8"
|
||||
env: TOXENV=mypy
|
||||
- python: "2.7"
|
||||
env: TOXENV=test-py27,codecov
|
||||
- python: "3.4"
|
||||
|
|
|
@ -97,7 +97,7 @@ def make_sentinel(name='_MISSING', var_name=""):
|
|||
if var_name:
|
||||
# superclass type hints don't allow str return type, but it is
|
||||
# allowed in the docs, hence the ignore[override] below
|
||||
def __reduce__(self): # type: ignore[override]
|
||||
def __reduce__(self):
|
||||
# type: () -> str
|
||||
return self.var_name
|
||||
|
||||
|
@ -448,7 +448,7 @@ def _optional(argument, default):
|
|||
|
||||
|
||||
def _typecheck(name, value, *types):
|
||||
# type: (Text, T, Type) -> T
|
||||
# type: (Text, T, Type[Any]) -> T
|
||||
"""
|
||||
Check that the given *value* is one of the given *types*, or raise an
|
||||
exception describing the problem using *name*.
|
||||
|
@ -479,7 +479,7 @@ def _textcheck(name, value, delims=frozenset(), nullable=False):
|
|||
|
||||
|
||||
def iter_pairs(iterable):
|
||||
# type: (Iterable) -> Iterator
|
||||
# type: (Iterable[Any]) -> Iterator[Any]
|
||||
"""
|
||||
Iterate over the (key, value) pairs in ``iterable``.
|
||||
|
||||
|
|
|
@ -7,9 +7,13 @@ class HyperlinkTestCase(TestCase):
|
|||
assertRaises method for Python 2.6 testing.
|
||||
"""
|
||||
def assertRaises( # type: ignore[override]
|
||||
self, expected_exception, callableObj=None, *args, **kwargs
|
||||
self,
|
||||
expected_exception, # type: Type[BaseException]
|
||||
callableObj=None, # type: Optional[Callable[..., Any]]
|
||||
*args, # type: Any
|
||||
**kwargs # type: Any
|
||||
):
|
||||
# type: (Type[BaseException], Optional[Callable], Any, Any) -> Any
|
||||
# type: (...) -> Any
|
||||
"""Fail unless an exception of class expected_exception is raised
|
||||
by callableObj when invoked with arguments args and keyword
|
||||
arguments kwargs. If a different type of exception is
|
||||
|
|
|
@ -1112,7 +1112,6 @@ class TestURL(HyperlinkTestCase):
|
|||
|
||||
attempt_unrooted_absolute = URL(host="foo", path=['bar'], rooted=False)
|
||||
normal_absolute = URL(host="foo", path=["bar"])
|
||||
attempted_rooted_replacement = normal_absolute.replace(rooted=True)
|
||||
self.assertEqual(attempt_unrooted_absolute, normal_absolute)
|
||||
self.assertEqual(normal_absolute.rooted, True)
|
||||
self.assertEqual(attempt_unrooted_absolute.rooted, True)
|
||||
|
|
25
tox.ini
25
tox.ini
|
@ -1,7 +1,7 @@
|
|||
[tox]
|
||||
|
||||
envlist =
|
||||
flake8
|
||||
flake8, mypy
|
||||
test-py{26,27,34,35,36,37,38,py,py3}
|
||||
coverage_report
|
||||
packaging
|
||||
|
@ -55,6 +55,8 @@ passenv =
|
|||
setenv =
|
||||
PY_MODULE=hyperlink
|
||||
|
||||
test: PYTHONPYCACHEPREFIX={envtmpdir}/pycache
|
||||
|
||||
test: COVERAGE_FILE={toxworkdir}/coverage.{envname}
|
||||
{coverage_report,codecov}: COVERAGE_FILE={toxworkdir}/coverage
|
||||
codecov: COVERAGE_XML={envlogdir}/coverage_report.xml
|
||||
|
@ -75,12 +77,9 @@ basepython = python3.8
|
|||
|
||||
skip_install = True
|
||||
|
||||
# Pin pydocstyle to version 3: see https://gitlab.com/pycqa/flake8-docstrings/issues/36
|
||||
deps =
|
||||
flake8-bugbear==19.8.0
|
||||
#flake8-docstrings==1.4.0
|
||||
#flake8-import-order==0.18.1
|
||||
#flake8-pep3101==1.2.1
|
||||
#flake8-docstrings==1.5.0
|
||||
flake8==3.7.9
|
||||
mccabe==0.6.1
|
||||
pep8-naming==0.9.1
|
||||
|
@ -142,11 +141,9 @@ basepython = python3.8
|
|||
|
||||
skip_install = True
|
||||
|
||||
|
||||
deps =
|
||||
mypy==0.750
|
||||
|
||||
|
||||
commands =
|
||||
mypy \
|
||||
--config-file="{toxinidir}/tox.ini" \
|
||||
|
@ -173,7 +170,11 @@ warn_return_any = True
|
|||
warn_unreachable = True
|
||||
warn_unused_ignores = True
|
||||
|
||||
[mypy-hyperlink._url]
|
||||
# Don't complain about dependencies known to lack type hints
|
||||
# 4 at time of writing (2020-20-01), so maybe disable this soon
|
||||
allow_untyped_defs = True
|
||||
|
||||
|
||||
[mypy-idna]
|
||||
ignore_missing_imports = True
|
||||
|
@ -196,8 +197,8 @@ deps =
|
|||
|
||||
commands =
|
||||
coverage combine
|
||||
coverage report
|
||||
coverage html
|
||||
- coverage report
|
||||
- coverage html
|
||||
|
||||
|
||||
##
|
||||
|
@ -217,6 +218,8 @@ deps =
|
|||
codecov==2.0.15
|
||||
|
||||
commands =
|
||||
# Note documentation for CI variables in default environment's passenv
|
||||
|
||||
coverage combine
|
||||
coverage xml -o "{env:COVERAGE_XML}"
|
||||
codecov --file="{env:COVERAGE_XML}" --env \
|
||||
|
@ -281,7 +284,9 @@ basepython = python
|
|||
deps =
|
||||
check-manifest==0.40
|
||||
readme_renderer==24.0
|
||||
twine==2.0.0
|
||||
|
||||
commands =
|
||||
check-manifest
|
||||
python setup.py check --metadata --restructuredtext --strict
|
||||
pip wheel --wheel-dir "{envtmpdir}/dist" --no-deps {toxinidir}
|
||||
twine check "{envtmpdir}/dist/"*
|
||||
|
|
Loading…
Reference in New Issue