Run isort in repo

This commit is contained in:
Alex Stokes 2019-08-02 22:36:19 -07:00 committed by Kevin Mai-Husan Chia
parent a92d933ed2
commit c8005c8113
55 changed files with 82 additions and 109 deletions

View File

@ -8,7 +8,6 @@ import multiaddr
from libp2p import new_node
from libp2p.peer.peerinfo import info_from_p2p_addr
PROTOCOL_ID = "/chat/1.0.0"

View File

@ -2,15 +2,15 @@ import asyncio
from Crypto.PublicKey import RSA
from .security.insecure_security import InsecureTransport
from .peer.peerstore import PeerStore
from .peer.id import ID
from .network.swarm import Swarm
from .host.basic_host import BasicHost
from .transport.upgrader import TransportUpgrader
from .transport.tcp.tcp import TCP
from .kademlia.network import KademliaServer
from .network.swarm import Swarm
from .peer.id import ID
from .peer.peerstore import PeerStore
from .routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter
from .security.insecure_security import InsecureTransport
from .transport.tcp.tcp import TCP
from .transport.upgrader import TransportUpgrader
async def cleanup_done_tasks():

View File

@ -3,11 +3,10 @@ from typing import Any, Awaitable, Callable, List, Sequence
import multiaddr
from libp2p.network.network_interface import INetwork
from libp2p.network.stream.net_stream_interface import INetStream
from libp2p.peer.id import ID
from libp2p.peer.peerinfo import PeerInfo
from libp2p.peer.peerstore_interface import IPeerStore
from libp2p.network.stream.net_stream_interface import INetStream
from libp2p.routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter
from .host_interface import IHost

View File

@ -4,12 +4,10 @@ from typing import Any, Awaitable, Callable, List, Sequence
import multiaddr
from libp2p.network.network_interface import INetwork
from libp2p.network.stream.net_stream_interface import INetStream
from libp2p.peer.id import ID
from libp2p.peer.peerinfo import PeerInfo
from libp2p.network.stream.net_stream_interface import INetStream
StreamHandlerFn = Callable[[INetStream], Awaitable[None]]

View File

@ -4,7 +4,6 @@ import logging
from .kad_peerinfo import KadPeerHeap, create_kad_peerinfo
from .utils import gather_dict
log = logging.getLogger(__name__)

View File

@ -1,11 +1,13 @@
import heapq
from operator import itemgetter
import random
from operator import itemgetter
from multiaddr import Multiaddr
from libp2p.peer.peerinfo import PeerInfo
from libp2p.peer.id import ID
from libp2p.peer.peerdata import PeerData
from libp2p.peer.peerinfo import PeerInfo
from .utils import digest
P_IP = "ip4"

View File

@ -1,16 +1,15 @@
"""
Package for interacting on the network at a high level.
"""
import pickle
import asyncio
import logging
import pickle
from .protocol import KademliaProtocol
from .utils import digest
from .storage import ForgetfulStorage
from .crawling import NodeSpiderCrawl, ValueSpiderCrawl
from .kad_peerinfo import create_kad_peerinfo
from .crawling import ValueSpiderCrawl
from .crawling import NodeSpiderCrawl
from .protocol import KademliaProtocol
from .storage import ForgetfulStorage
from .utils import digest
log = logging.getLogger(__name__)

View File

@ -1,12 +1,12 @@
import random
import asyncio
import logging
import random
from rpcudp.protocol import RPCProtocol
from .kad_peerinfo import create_kad_peerinfo
from .routing import RoutingTable
log = logging.getLogger(__name__)

View File

@ -1,10 +1,10 @@
import heapq
import time
import operator
import asyncio
from collections import OrderedDict
from .utils import OrderedSet, shared_prefix, bytes_to_bit_string
import heapq
import operator
import time
from .utils import OrderedSet, bytes_to_bit_string, shared_prefix
class KBucket:

View File

@ -1,8 +1,8 @@
import time
from abc import ABC, abstractmethod
from collections import OrderedDict
from itertools import takewhile
import operator
from collections import OrderedDict
from abc import abstractmethod, ABC
import time
class IStorage(ABC):

View File

@ -1,9 +1,9 @@
"""
General catchall for functions that don't make sense as methods.
"""
import asyncio
import hashlib
import operator
import asyncio
async def gather_dict(dic):

View File

@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import Awaitable, Callable, Dict, Sequence, TYPE_CHECKING
from typing import TYPE_CHECKING, Awaitable, Callable, Dict, Sequence
from multiaddr import Multiaddr

View File

@ -3,9 +3,8 @@ from typing import TYPE_CHECKING
from multiaddr import Multiaddr
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
from libp2p.network.stream.net_stream_interface import INetStream
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
if TYPE_CHECKING:
from .network_interface import INetwork

View File

@ -10,18 +10,16 @@ from libp2p.protocol_muxer.multiselect_client import MultiselectClient
from libp2p.routing.interfaces import IPeerRouting
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
from libp2p.stream_muxer.muxed_stream_interface import IMuxedStream
from libp2p.transport.upgrader import TransportUpgrader
from libp2p.transport.transport_interface import ITransport
from libp2p.transport.listener_interface import IListener
from libp2p.transport.transport_interface import ITransport
from libp2p.transport.upgrader import TransportUpgrader
from .connection.raw_connection import RawConnection
from .network_interface import INetwork
from .notifee_interface import INotifee
from .connection.raw_connection import RawConnection
from .stream.net_stream import NetStream
from .stream.net_stream_interface import INetStream
StreamHandlerFn = Callable[[INetStream], Awaitable[None]]

View File

@ -1,7 +1,6 @@
from abc import ABC, abstractmethod
from typing import List, Sequence
from multiaddr import Multiaddr
from .id import ID

View File

@ -2,7 +2,6 @@ import hashlib
from typing import Union
import base58
import multihash

View File

@ -1,7 +1,6 @@
from abc import abstractmethod
from typing import List, Sequence
from .addrbook_interface import IAddrBook
from .id import ID
from .peerinfo import PeerInfo

View File

@ -1,6 +1,5 @@
from .multiselect_muxer_interface import IMultiselectMuxer
from .multiselect_communicator import MultiselectCommunicator
from .multiselect_muxer_interface import IMultiselectMuxer
MULTISELECT_PROTOCOL_ID = "/multistream/1.0.0"
PROTOCOL_NOT_FOUND_MSG = "na"

View File

@ -1,7 +1,6 @@
from .multiselect_client_interface import IMultiselectClient
from .multiselect_communicator import MultiselectCommunicator
MULTISELECT_PROTOCOL_ID = "/multistream/1.0.0"
PROTOCOL_NOT_FOUND_MSG = "na"

View File

@ -1,7 +1,7 @@
from ast import literal_eval
import asyncio
import random
from typing import Any, Dict, Iterable, List, Set, Sequence
from typing import Any, Dict, Iterable, List, Sequence, Set
from libp2p.peer.id import ID

View File

@ -1,13 +1,12 @@
import asyncio
import time
from typing import Any, Dict, List, Tuple, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Dict, List, Tuple
from lru import LRU
from libp2p.host.host_interface import IHost
from libp2p.peer.id import ID
from libp2p.network.stream.net_stream_interface import INetStream
from libp2p.peer.id import ID
from .pb import rpc_pb2
from .pubsub_notifee import PubsubNotifee

View File

@ -4,9 +4,8 @@ from multiaddr import Multiaddr
from libp2p.network.network_interface import INetwork
from libp2p.network.notifee_interface import INotifee
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
from libp2p.network.stream.net_stream_interface import INetStream
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
if TYPE_CHECKING:
import asyncio

View File

@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import List, TYPE_CHECKING
from typing import TYPE_CHECKING, List
from libp2p.peer.id import ID

View File

@ -1,7 +1,7 @@
from libp2p.security.secure_transport_interface import ISecureTransport
from libp2p.security.secure_conn_interface import ISecureConn
from typing import TYPE_CHECKING, Any, Dict, cast
from typing import TYPE_CHECKING, Dict, Any, cast
from libp2p.security.secure_conn_interface import ISecureConn
from libp2p.security.secure_transport_interface import ISecureTransport
if TYPE_CHECKING:
from libp2p.network.connection.raw_connection_interface import IRawConnection

View File

@ -1,5 +1,4 @@
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
if TYPE_CHECKING:

View File

@ -1,5 +1,4 @@
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
if TYPE_CHECKING:

View File

@ -1,8 +1,8 @@
from abc import ABC
from libp2p.protocol_muxer.multiselect_client import MultiselectClient
from libp2p.protocol_muxer.multiselect import Multiselect
from typing import TYPE_CHECKING, Dict, NewType
from typing import TYPE_CHECKING, NewType, Dict
from libp2p.protocol_muxer.multiselect import Multiselect
from libp2p.protocol_muxer.multiselect_client import MultiselectClient
if TYPE_CHECKING:
from libp2p.network.connection.raw_connection_interface import IRawConnection

View File

@ -1,9 +1,9 @@
import asyncio
from libp2p.security.secure_transport_interface import ISecureTransport
from libp2p.security.secure_conn_interface import ISecureConn
from typing import TYPE_CHECKING, cast
from libp2p.security.secure_conn_interface import ISecureConn
from libp2p.security.secure_transport_interface import ISecureTransport
if TYPE_CHECKING:
from libp2p.network.connection.raw_connection_interface import IRawConnection
from libp2p.peer.id import ID

View File

@ -1,4 +1,3 @@
from typing import TypeVar, Dict, Any, NewType
from typing import Any, Dict, NewType, TypeVar
TSecurityDetails = NewType("TSecurityDetails", Dict[str, str])

View File

@ -1,8 +1,8 @@
import asyncio
from .utils import encode_uvarint, decode_uvarint_from_stream, get_flag
from .mplex_stream import MplexStream
from ..muxed_connection_interface import IMuxedConn
from .mplex_stream import MplexStream
from .utils import decode_uvarint_from_stream, encode_uvarint, get_flag
class Mplex(IMuxedConn):

View File

@ -1,5 +1,6 @@
import asyncio
import struct
from .constants import HEADER_TAGS

View File

@ -1,5 +1,5 @@
from libp2p.stream_muxer.mplex.mplex import Mplex
from libp2p.security.security_multistream import SecurityMultistream
from libp2p.stream_muxer.mplex.mplex import Mplex
class TransportUpgrader:

View File

@ -1,6 +1,5 @@
import setuptools
classifiers = [f"Programming Language :: Python :: {version}" for version in ["3.7"]]

View File

@ -1,12 +1,12 @@
import pytest
import asyncio
import multiaddr
from tests.utils import cleanup, set_up_nodes_by_transport_opt
import multiaddr
import pytest
from libp2p import new_node
from libp2p.peer.peerinfo import info_from_p2p_addr
from libp2p.protocol_muxer.multiselect_client import MultiselectClientError
from tests.utils import cleanup, set_up_nodes_by_transport_opt
PROTOCOL_ID = "/chat/1.0.0"

View File

@ -1,4 +1,5 @@
import pytest
from libp2p.kademlia.network import KademliaServer

View File

@ -1,4 +1,5 @@
import pytest
from libp2p.kademlia.network import KademliaServer

View File

@ -1,8 +1,8 @@
import multiaddr
import pytest
from tests.utils import cleanup, set_up_nodes_by_transport_opt
from libp2p.peer.peerinfo import info_from_p2p_addr
from tests.utils import cleanup, set_up_nodes_by_transport_opt
@pytest.mark.asyncio

View File

@ -9,17 +9,17 @@ TODO: Add tests for closed_stream disconnected, listen_close when those
features are implemented in swarm
"""
import pytest
import multiaddr
import pytest
from libp2p import initialize_default_swarm, new_node
from libp2p.host.basic_host import BasicHost
from libp2p.network.notifee_interface import INotifee
from tests.utils import (
cleanup,
echo_stream_handler,
perform_two_host_set_up_custom_handler,
)
from libp2p import new_node, initialize_default_swarm
from libp2p.network.notifee_interface import INotifee
from libp2p.host.basic_host import BasicHost
class MyNotifee(INotifee):

View File

@ -1,4 +1,5 @@
import asyncio
import pytest

View File

@ -1,7 +1,6 @@
import pytest
from libp2p.peer.peerstore import PeerStoreError
from libp2p.peer.peerstore import PeerStore
from libp2p.peer.peerstore import PeerStore, PeerStoreError
# Testing methods from IAddrBook base class.

View File

@ -1,10 +1,11 @@
import random
from Crypto.PublicKey import RSA
import base58
import multihash
import pytest
import base58
from Crypto.PublicKey import RSA
from libp2p.peer.id import ID
from libp2p.peer.id import ID
ALPHABETS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"

View File

@ -1,13 +1,11 @@
import random
import multiaddr
import pytest
import multiaddr
from libp2p.peer.peerinfo import PeerInfo, info_from_p2p_addr, InvalidAddrError
from libp2p.peer.peerdata import PeerData
from libp2p.peer.id import ID
from libp2p.peer.peerdata import PeerData
from libp2p.peer.peerinfo import InvalidAddrError, PeerInfo, info_from_p2p_addr
ALPHABETS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"

View File

@ -1,8 +1,6 @@
import pytest
from libp2p.peer.peerstore import PeerStoreError
from libp2p.peer.peerstore import PeerStore
from libp2p.peer.peerstore import PeerStore, PeerStoreError
# Testing methods from IPeerMetadata base class.

View File

@ -1,7 +1,7 @@
import pytest
from tests.utils import cleanup, set_up_nodes_by_transport_opt
from libp2p.protocol_muxer.multiselect_client import MultiselectClientError
from tests.utils import cleanup, set_up_nodes_by_transport_opt
# TODO: Add tests for multiple streams being opened on different
# protocols through the same connection

View File

@ -1,6 +1,5 @@
from typing import NamedTuple
FLOODSUB_PROTOCOL_ID = "/floodsub/1.0.0"
GOSSIPSUB_PROTOCOL_ID = "/gossipsub/1.0.0"

View File

@ -4,13 +4,11 @@ import uuid
from libp2p.host.host_interface import IHost
from libp2p.pubsub.floodsub import FloodSub
from libp2p.pubsub.pubsub import Pubsub
from tests.configs import LISTEN_MADDR
from .factories import FloodsubFactory, PubsubFactory
from .utils import message_id_generator
CRYPTO_TOPIC = "ethereum"
# Message format:

View File

@ -7,10 +7,9 @@ from libp2p.host.basic_host import BasicHost
from libp2p.pubsub.floodsub import FloodSub
from libp2p.pubsub.gossipsub import GossipSub
from libp2p.pubsub.pubsub import Pubsub
from tests.configs import LISTEN_MADDR
from .configs import FLOODSUB_PROTOCOL_ID, GOSSIPSUB_PROTOCOL_ID, GOSSIPSUB_PARAMS
from .configs import FLOODSUB_PROTOCOL_ID, GOSSIPSUB_PARAMS, GOSSIPSUB_PROTOCOL_ID
def swarm_factory():

View File

@ -8,7 +8,6 @@ from tests.utils import cleanup, connect
from .configs import FLOODSUB_PROTOCOL_ID
from .factories import PubsubFactory
SUPPORTED_PROTOCOLS = [FLOODSUB_PROTOCOL_ID]
FLOODSUB_PROTOCOL_TEST_CASES = [

View File

@ -3,13 +3,12 @@ import asyncio
import pytest
from libp2p.peer.id import ID
from tests.utils import cleanup, connect
from .factories import FloodsubFactory
from .floodsub_integration_test_settings import (
perform_test_from_obj,
floodsub_protocol_pytest_params,
perform_test_from_obj,
)

View File

@ -5,8 +5,8 @@ import pytest
from .configs import FLOODSUB_PROTOCOL_ID
from .factories import GossipsubFactory
from .floodsub_integration_test_settings import (
perform_test_from_obj,
floodsub_protocol_pytest_params,
perform_test_from_obj,
)

View File

@ -6,12 +6,10 @@ import pytest
from libp2p.peer.id import ID
from libp2p.pubsub.pb import rpc_pb2
from tests.utils import connect
from .utils import make_pubsub_msg
TESTING_TOPIC = "TEST_SUBSCRIBE"
TESTING_DATA = b"data"

View File

@ -3,7 +3,6 @@ from typing import Sequence
from libp2p.peer.id import ID
from libp2p.pubsub.pb import rpc_pb2
from tests.utils import connect

View File

@ -1,7 +1,7 @@
import pytest
from libp2p.peer.id import ID
from libp2p.kademlia.network import KademliaServer
from libp2p.peer.id import ID
from libp2p.routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter

View File

@ -1,4 +1,5 @@
import asyncio
import multiaddr
import pytest
@ -7,10 +8,8 @@ from libp2p.peer.peerinfo import info_from_p2p_addr
from libp2p.protocol_muxer.multiselect_client import MultiselectClientError
from libp2p.security.insecure_security import InsecureTransport
from libp2p.security.simple_security import SimpleSecurityTransport
from tests.utils import cleanup, connect
# TODO: Add tests for multiple streams being opened on different
# protocols through the same connection

View File

@ -1,5 +1,6 @@
from contextlib import suppress
import asyncio
from contextlib import suppress
import multiaddr
from libp2p import new_node