Skip to content

Commit eb8bc08

Browse files
authored
Merge pull request #86 from python-hyper/travis-lint
Add flake8 and mypy to Travis
2 parents d5c2c28 + 86a4736 commit eb8bc08

5 files changed

Lines changed: 28 additions & 16 deletions

File tree

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ language: python
55

66
matrix:
77
include:
8+
- python: "3.8"
9+
env: TOXENV=flake8
10+
- python: "3.8"
11+
env: TOXENV=mypy
812
- python: "2.7"
913
env: TOXENV=test-py27,codecov
1014
- python: "3.4"

src/hyperlink/_url.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __repr__(self):
9797
if var_name:
9898
# superclass type hints don't allow str return type, but it is
9999
# allowed in the docs, hence the ignore[override] below
100-
def __reduce__(self): # type: ignore[override]
100+
def __reduce__(self):
101101
# type: () -> str
102102
return self.var_name
103103

@@ -448,7 +448,7 @@ def _optional(argument, default):
448448

449449

450450
def _typecheck(name, value, *types):
451-
# type: (Text, T, Type) -> T
451+
# type: (Text, T, Type[Any]) -> T
452452
"""
453453
Check that the given *value* is one of the given *types*, or raise an
454454
exception describing the problem using *name*.
@@ -479,7 +479,7 @@ def _textcheck(name, value, delims=frozenset(), nullable=False):
479479

480480

481481
def iter_pairs(iterable):
482-
# type: (Iterable) -> Iterator
482+
# type: (Iterable[Any]) -> Iterator[Any]
483483
"""
484484
Iterate over the (key, value) pairs in ``iterable``.
485485

src/hyperlink/test/common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ class HyperlinkTestCase(TestCase):
77
assertRaises method for Python 2.6 testing.
88
"""
99
def assertRaises( # type: ignore[override]
10-
self, expected_exception, callableObj=None, *args, **kwargs
10+
self,
11+
expected_exception, # type: Type[BaseException]
12+
callableObj=None, # type: Optional[Callable[..., Any]]
13+
*args, # type: Any
14+
**kwargs # type: Any
1115
):
12-
# type: (Type[BaseException], Optional[Callable], Any, Any) -> Any
16+
# type: (...) -> Any
1317
"""Fail unless an exception of class expected_exception is raised
1418
by callableObj when invoked with arguments args and keyword
1519
arguments kwargs. If a different type of exception is

src/hyperlink/test/test_url.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,6 @@ def test_autorooted(self):
11121112

11131113
attempt_unrooted_absolute = URL(host="foo", path=['bar'], rooted=False)
11141114
normal_absolute = URL(host="foo", path=["bar"])
1115-
attempted_rooted_replacement = normal_absolute.replace(rooted=True)
11161115
self.assertEqual(attempt_unrooted_absolute, normal_absolute)
11171116
self.assertEqual(normal_absolute.rooted, True)
11181117
self.assertEqual(attempt_unrooted_absolute.rooted, True)

tox.ini

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22

33
envlist =
4-
flake8
4+
flake8, mypy
55
test-py{26,27,34,35,36,37,38,py,py3}
66
coverage_report
77
packaging
@@ -55,6 +55,8 @@ passenv =
5555
setenv =
5656
PY_MODULE=hyperlink
5757

58+
test: PYTHONPYCACHEPREFIX={envtmpdir}/pycache
59+
5860
test: COVERAGE_FILE={toxworkdir}/coverage.{envname}
5961
{coverage_report,codecov}: COVERAGE_FILE={toxworkdir}/coverage
6062
codecov: COVERAGE_XML={envlogdir}/coverage_report.xml
@@ -75,12 +77,9 @@ basepython = python3.8
7577

7678
skip_install = True
7779

78-
# Pin pydocstyle to version 3: see https://gitlab.com/pycqa/flake8-docstrings/issues/36
7980
deps =
8081
flake8-bugbear==19.8.0
81-
#flake8-docstrings==1.4.0
82-
#flake8-import-order==0.18.1
83-
#flake8-pep3101==1.2.1
82+
#flake8-docstrings==1.5.0
8483
flake8==3.7.9
8584
mccabe==0.6.1
8685
pep8-naming==0.9.1
@@ -142,11 +141,9 @@ basepython = python3.8
142141

143142
skip_install = True
144143

145-
146144
deps =
147145
mypy==0.750
148146

149-
150147
commands =
151148
mypy \
152149
--config-file="{toxinidir}/tox.ini" \
@@ -173,7 +170,11 @@ warn_return_any = True
173170
warn_unreachable = True
174171
warn_unused_ignores = True
175172

173+
[mypy-hyperlink._url]
176174
# Don't complain about dependencies known to lack type hints
175+
# 4 at time of writing (2020-20-01), so maybe disable this soon
176+
allow_untyped_defs = True
177+
177178

178179
[mypy-idna]
179180
ignore_missing_imports = True
@@ -196,8 +197,8 @@ deps =
196197

197198
commands =
198199
coverage combine
199-
coverage report
200-
coverage html
200+
- coverage report
201+
- coverage html
201202

202203

203204
##
@@ -217,6 +218,8 @@ deps =
217218
codecov==2.0.15
218219

219220
commands =
221+
# Note documentation for CI variables in default environment's passenv
222+
220223
coverage combine
221224
coverage xml -o "{env:COVERAGE_XML}"
222225
codecov --file="{env:COVERAGE_XML}" --env \
@@ -281,7 +284,9 @@ basepython = python
281284
deps =
282285
check-manifest==0.40
283286
readme_renderer==24.0
287+
twine==2.0.0
284288

285289
commands =
286290
check-manifest
287-
python setup.py check --metadata --restructuredtext --strict
291+
pip wheel --wheel-dir "{envtmpdir}/dist" --no-deps {toxinidir}
292+
twine check "{envtmpdir}/dist/"*

0 commit comments

Comments
 (0)