Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flake8 and mypy to Travis #86

Merged
merged 13 commits into from
Jan 21, 2020
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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"
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlink/test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class HyperlinkTestCase(TestCase):
"""This type mostly exists to provide a backwards-compatible
assertRaises method for Python 2.6 testing.
"""
def assertRaises( # type: ignore[override] Doesn't match superclass, meh
def assertRaises( # type: ignore[override]
self, expected_exception, callableObj=None, *args, **kwargs
):
# type: (Type[BaseException], Optional[Callable], Any, Any) -> Any
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlink/test/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_assertRaisesContextManager(self):
with self.hyperlink_test.assertRaises(_ExpectedException) as cm:
raise _ExpectedException

self.assertTrue( # type: ignore[misc] unreachable
self.assertTrue( # type: ignore[misc] # unreachable
isinstance(cm.exception, _ExpectedException)
)

Expand Down
1 change: 0 additions & 1 deletion src/hyperlink/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from .common import HyperlinkTestCase
from .._socket import inet_pton


class TestSocket(HyperlinkTestCase):
def test_inet_pton_ipv4_valid(self):
# type: () -> None
Expand Down
1 change: 0 additions & 1 deletion src/hyperlink/test/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glyph: here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird. that's a real bug. we should be asserting something about that object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that asserting something about that object is unrelated to this PR, though, and is an example of why landing this PR would be good :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how you want to address that. Can you open a PR with a fix or an issue to track it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, this came via #91

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess what I meant was I should have asserted something about that object :).

You can feel free to just clean it up here for the time being, and assign any resulting issue to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #99 for replacing this.

self.assertEqual(attempt_unrooted_absolute, normal_absolute)
self.assertEqual(normal_absolute.rooted, True)
self.assertEqual(attempt_unrooted_absolute.rooted, True)
Expand Down
25 changes: 14 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]

envlist =
flake8
flake8, mypy
test-py{26,27,34,35,36,37,38,py,py3}
coverage_report
packaging
Expand Down Expand Up @@ -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
Expand All @@ -75,16 +77,15 @@ 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
pydocstyle==4.0.1
# pin pyflakes pending a release with https://github.com/PyCQA/pyflakes/pull/455
git+git://github.com/PyCQA/pyflakes@ffe9386#egg=pyflakes

commands =
flake8 {posargs:src/{env:PY_MODULE}}
Expand Down Expand Up @@ -140,11 +141,9 @@ basepython = python3.8

skip_install = True


deps =
mypy==0.750


commands =
mypy \
--config-file="{toxinidir}/tox.ini" \
Expand Down Expand Up @@ -172,7 +171,7 @@ warn_unused_ignores = True
# Enable these over time
check_untyped_defs = False

# Disable some checks until effected files fully adopt mypy
# Don't complain about dependencies known to lack type hints

[mypy-hyperlink._url]
allow_untyped_defs = True
Expand All @@ -198,8 +197,8 @@ deps =

commands =
coverage combine
coverage report
coverage html
- coverage report
- coverage html


##
Expand All @@ -219,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 \
Expand Down Expand Up @@ -283,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/"*