From cab0e0c1c43a468afaf84e2a688fbb7dcf4ba158 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen Date: Mon, 4 Nov 2019 21:05:12 +0100 Subject: [PATCH 1/3] Add warn_unreachable=True mypy config --- mypy.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/mypy.ini b/mypy.ini index 3da7cfa5..77624137 100644 --- a/mypy.ini +++ b/mypy.ini @@ -9,6 +9,7 @@ disallow_any_generics = True disallow_untyped_calls = True warn_redundant_casts = True warn_unused_configs = True +warn_unreachable = True strict_equality = True [mypy-libp2p.kademlia.*] From 69279108bcf90eddd836dbdeef9aeae166cfec5b Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen Date: Mon, 4 Nov 2019 21:16:09 +0100 Subject: [PATCH 2/3] Add flake8-bugbear --- setup.py | 1 + tests_interop/daemon.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f9c2668d..30c820e9 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ extras_require = { "black==19.3b0", "isort==4.3.21", "flake8>=3.7.7,<4.0.0", + "flake8-bugbear", ], "dev": ["tox>=3.13.2,<4.0.0", "docformatter"], } diff --git a/tests_interop/daemon.py b/tests_interop/daemon.py index 83aa82d3..a1b60fa9 100644 --- a/tests_interop/daemon.py +++ b/tests_interop/daemon.py @@ -32,7 +32,9 @@ async def try_until_success(coro_func, timeout=TIMEOUT_DURATION): break if (time.monotonic() - t_start) >= timeout: # timeout - assert False, f"{coro_func} is still failing after `{timeout}` seconds" + raise AssertionError( + f"{coro_func} is still failing after `{timeout}` seconds" + ) await asyncio.sleep(0.01) From 23848039fdec26c6e7aabaffdd456f1efcb1c17c Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen Date: Tue, 5 Nov 2019 01:26:08 +0100 Subject: [PATCH 3/3] Use pytest.fail() to fail test --- tests_interop/daemon.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests_interop/daemon.py b/tests_interop/daemon.py index a1b60fa9..f17ef110 100644 --- a/tests_interop/daemon.py +++ b/tests_interop/daemon.py @@ -5,6 +5,7 @@ from typing import Any, List import multiaddr from multiaddr import Multiaddr from p2pclient import Client +import pytest from libp2p.peer.id import ID from libp2p.peer.peerinfo import PeerInfo, info_from_p2p_addr @@ -32,9 +33,7 @@ async def try_until_success(coro_func, timeout=TIMEOUT_DURATION): break if (time.monotonic() - t_start) >= timeout: # timeout - raise AssertionError( - f"{coro_func} is still failing after `{timeout}` seconds" - ) + pytest.fail(f"{coro_func} is still failing after `{timeout}` seconds") await asyncio.sleep(0.01)