Skip to content

Commit

Permalink
rename typing.py to custom_types.py for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
pacrob committed Feb 2, 2025
1 parent d0234bb commit b8fd59d
Show file tree
Hide file tree
Showing 34 changed files with 92 additions and 91 deletions.
6 changes: 3 additions & 3 deletions examples/chat/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
from libp2p import (
new_host,
)
from libp2p.custom_types import (
TProtocol,
)
from libp2p.network.stream.net_stream_interface import (
INetStream,
)
from libp2p.peer.peerinfo import (
info_from_p2p_addr,
)
from libp2p.typing import (
TProtocol,
)

PROTOCOL_ID = TProtocol("/chat/1.0.0")
MAX_READ_LEN = 2**32 - 1
Expand Down
6 changes: 3 additions & 3 deletions examples/echo/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
from libp2p.crypto.secp256k1 import (
create_new_key_pair,
)
from libp2p.custom_types import (
TProtocol,
)
from libp2p.network.stream.net_stream_interface import (
INetStream,
)
from libp2p.peer.peerinfo import (
info_from_p2p_addr,
)
from libp2p.typing import (
TProtocol,
)

PROTOCOL_ID = TProtocol("/echo/1.0.0")

Expand Down
6 changes: 3 additions & 3 deletions examples/ping/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
from libp2p import (
new_host,
)
from libp2p.custom_types import (
TProtocol,
)
from libp2p.network.stream.net_stream_interface import (
INetStream,
)
from libp2p.peer.peerinfo import (
info_from_p2p_addr,
)
from libp2p.typing import (
TProtocol,
)

PING_PROTOCOL_ID = TProtocol("/ipfs/ping/1.0.0")
PING_LENGTH = 32
Expand Down
6 changes: 3 additions & 3 deletions libp2p/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from libp2p.crypto.rsa import (
create_new_key_pair,
)
from libp2p.custom_types import (
TProtocol,
)
from libp2p.host.basic_host import (
BasicHost,
)
Expand Down Expand Up @@ -52,9 +55,6 @@
from libp2p.transport.upgrader import (
TransportUpgrader,
)
from libp2p.typing import (
TProtocol,
)


def generate_new_rsa_identity() -> KeyPair:
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions libp2p/host/basic_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
PrivateKey,
PublicKey,
)
from libp2p.custom_types import (
StreamHandlerFn,
TProtocol,
)
from libp2p.host.defaults import (
get_default_protocols,
)
Expand Down Expand Up @@ -53,10 +57,6 @@
from libp2p.tools.async_service import (
background_trio_service,
)
from libp2p.typing import (
StreamHandlerFn,
TProtocol,
)

from .host_interface import (
IHost,
Expand Down
2 changes: 1 addition & 1 deletion libp2p/host/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from libp2p.identity.identify.protocol import ID as IdentifyID

if TYPE_CHECKING:
from libp2p.typing import (
from libp2p.custom_types import (
StreamHandlerFn,
TProtocol,
)
Expand Down
8 changes: 4 additions & 4 deletions libp2p/host/host_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
PrivateKey,
PublicKey,
)
from libp2p.custom_types import (
StreamHandlerFn,
TProtocol,
)
from libp2p.network.network_interface import (
INetworkService,
)
Expand All @@ -28,10 +32,6 @@
from libp2p.peer.peerinfo import (
PeerInfo,
)
from libp2p.typing import (
StreamHandlerFn,
TProtocol,
)


class IHost(ABC):
Expand Down
6 changes: 3 additions & 3 deletions libp2p/host/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import trio

from libp2p.custom_types import (
TProtocol,
)
from libp2p.host.host_interface import (
IHost,
)
Expand All @@ -16,9 +19,6 @@
INetStream,
)
from libp2p.peer.id import ID as PeerID
from libp2p.typing import (
TProtocol,
)

ID = TProtocol("/ipfs/ping/1.0.0")
PING_LENGTH = 32
Expand Down
8 changes: 4 additions & 4 deletions libp2p/identity/identify/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
Multiaddr,
)

from libp2p.custom_types import (
StreamHandlerFn,
TProtocol,
)
from libp2p.host.host_interface import (
IHost,
)
Expand All @@ -13,10 +17,6 @@
from libp2p.network.stream.net_stream_interface import (
INetStream,
)
from libp2p.typing import (
StreamHandlerFn,
TProtocol,
)

from .pb.identify_pb2 import (
Identify,
Expand Down
6 changes: 3 additions & 3 deletions libp2p/network/network_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
Multiaddr,
)

from libp2p.custom_types import (
StreamHandlerFn,
)
from libp2p.network.connection.net_connection_interface import (
INetConn,
)
Expand All @@ -28,9 +31,6 @@
from libp2p.transport.listener_interface import (
IListener,
)
from libp2p.typing import (
StreamHandlerFn,
)

from .stream.net_stream_interface import (
INetStream,
Expand Down
6 changes: 3 additions & 3 deletions libp2p/network/stream/net_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Optional,
)

from libp2p.custom_types import (
TProtocol,
)
from libp2p.stream_muxer.abc import (
IMuxedStream,
)
Expand All @@ -10,9 +13,6 @@
MuxedStreamEOF,
MuxedStreamReset,
)
from libp2p.typing import (
TProtocol,
)

from .exceptions import (
StreamClosed,
Expand Down
6 changes: 3 additions & 3 deletions libp2p/network/stream/net_stream_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
abstractmethod,
)

from libp2p.custom_types import (
TProtocol,
)
from libp2p.io.abc import (
ReadWriteCloser,
)
from libp2p.stream_muxer.abc import (
IMuxedConn,
)
from libp2p.typing import (
TProtocol,
)


class INetStream(ReadWriteCloser):
Expand Down
6 changes: 3 additions & 3 deletions libp2p/network/swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
)
import trio

from libp2p.custom_types import (
StreamHandlerFn,
)
from libp2p.io.abc import (
ReadWriteCloser,
)
Expand Down Expand Up @@ -43,9 +46,6 @@
from libp2p.transport.upgrader import (
TransportUpgrader,
)
from libp2p.typing import (
StreamHandlerFn,
)

from ..exceptions import (
MultiError,
Expand Down
2 changes: 1 addition & 1 deletion libp2p/protocol_muxer/multiselect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from libp2p.typing import (
from libp2p.custom_types import (
StreamHandlerFn,
TProtocol,
)
Expand Down
2 changes: 1 addition & 1 deletion libp2p/protocol_muxer/multiselect_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Sequence,
)

from libp2p.typing import (
from libp2p.custom_types import (
TProtocol,
)

Expand Down
6 changes: 3 additions & 3 deletions libp2p/protocol_muxer/multiselect_client_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
Sequence,
)

from libp2p.custom_types import (
TProtocol,
)
from libp2p.protocol_muxer.multiselect_communicator_interface import (
IMultiselectCommunicator,
)
from libp2p.typing import (
TProtocol,
)


class IMultiselectClient(ABC):
Expand Down
2 changes: 1 addition & 1 deletion libp2p/protocol_muxer/multiselect_muxer_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
abstractmethod,
)

from libp2p.typing import (
from libp2p.custom_types import (
StreamHandlerFn,
TProtocol,
)
Expand Down
6 changes: 3 additions & 3 deletions libp2p/pubsub/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
AsyncContextManager,
)

from libp2p.custom_types import (
TProtocol,
)
from libp2p.peer.id import (
ID,
)
from libp2p.tools.async_service import (
ServiceAPI,
)
from libp2p.typing import (
TProtocol,
)

from .pb import (
rpc_pb2,
Expand Down
6 changes: 3 additions & 3 deletions libp2p/pubsub/floodsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

import trio

from libp2p.custom_types import (
TProtocol,
)
from libp2p.network.stream.exceptions import (
StreamClosed,
)
from libp2p.peer.id import (
ID,
)
from libp2p.typing import (
TProtocol,
)
from libp2p.utils import (
encode_varint_prefixed,
)
Expand Down
6 changes: 3 additions & 3 deletions libp2p/pubsub/gossipsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

import trio

from libp2p.custom_types import (
TProtocol,
)
from libp2p.network.stream.exceptions import (
StreamClosed,
)
Expand All @@ -29,9 +32,6 @@
from libp2p.tools.async_service import (
Service,
)
from libp2p.typing import (
TProtocol,
)
from libp2p.utils import (
encode_varint_prefixed,
)
Expand Down
6 changes: 3 additions & 3 deletions libp2p/pubsub/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
from libp2p.crypto.keys import (
PrivateKey,
)
from libp2p.custom_types import (
TProtocol,
)
from libp2p.exceptions import (
ParseError,
ValidationError,
Expand Down Expand Up @@ -53,9 +56,6 @@
from libp2p.tools.async_service import (
Service,
)
from libp2p.typing import (
TProtocol,
)
from libp2p.utils import (
encode_varint_prefixed,
read_varint_prefixed_bytes,
Expand Down
6 changes: 3 additions & 3 deletions libp2p/security/insecure/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from libp2p.crypto.serialization import (
deserialize_public_key,
)
from libp2p.custom_types import (
TProtocol,
)
from libp2p.io.abc import (
ReadWriteCloser,
)
Expand Down Expand Up @@ -38,9 +41,6 @@
from libp2p.security.secure_conn_interface import (
ISecureConn,
)
from libp2p.typing import (
TProtocol,
)

from .pb import (
plaintext_pb2,
Expand Down
Loading

0 comments on commit b8fd59d

Please sign in to comment.