diff --git a/.travis.yml b/.travis.yml index fe7acec0..6e9403cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/src/hyperlink/_url.py b/src/hyperlink/_url.py index 15f6cc9d..f39525d3 100644 --- a/src/hyperlink/_url.py +++ b/src/hyperlink/_url.py @@ -97,7 +97,7 @@ def __repr__(self): 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``. diff --git a/src/hyperlink/test/common.py b/src/hyperlink/test/common.py index a2961f45..f489266e 100644 --- a/src/hyperlink/test/common.py +++ b/src/hyperlink/test/common.py @@ -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 diff --git a/src/hyperlink/test/test_url.py b/src/hyperlink/test/test_url.py index dd554fa5..fa5c7bf1 100644 --- a/src/hyperlink/test/test_url.py +++ b/src/hyperlink/test/test_url.py @@ -1112,7 +1112,6 @@ def test_autorooted(self): 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) diff --git a/tox.ini b/tox.ini index eb2f07be..bfd3c7b4 100644 --- a/tox.ini +++ b/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/"*