Skip to content

Commit cd019ce

Browse files
committed
fix(webrtc): resolve lint and type declaration issues
1 parent fd22cd6 commit cd019ce

22 files changed

+1846
-1773
lines changed

libp2p/transport/webrtc/__init__.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class WebRTCCodec:
3434
"""Codec for WebRTC protocol (empty protocol with no value)."""
3535
SIZE = 0
3636
IS_PATH = False
37-
37+
3838
@staticmethod
3939
def to_bytes(proto: Any, s: str) -> bytes:
4040
return b""
41-
41+
4242
@staticmethod
4343
def to_string(proto: Any, b: bytes) -> str:
4444
return ""
@@ -48,11 +48,11 @@ class WebRTCDirectCodec:
4848
"""Codec for WebRTC-Direct protocol (empty protocol with no value)."""
4949
SIZE = 0
5050
IS_PATH = False
51-
51+
5252
@staticmethod
5353
def to_bytes(proto: Any, s: str) -> bytes:
5454
return b""
55-
55+
5656
@staticmethod
5757
def to_string(proto: Any, b: bytes) -> str:
5858
return ""
@@ -63,7 +63,7 @@ class CerthashCodec:
6363
SIZE = -1 # Variable size protocol
6464
LENGTH_PREFIXED_VAR_SIZE = -1
6565
IS_PATH = False
66-
66+
6767
@staticmethod
6868
def to_bytes(proto: Any, s: str) -> bytes:
6969
if not s:
@@ -84,7 +84,7 @@ def to_bytes(proto: Any, s: str) -> bytes:
8484
return base64.urlsafe_b64decode(s_bytes)
8585
except Exception:
8686
return s.encode('utf-8')
87-
87+
8888
@staticmethod
8989
def to_string(proto: Any, b: bytes) -> str:
9090
if not b:
@@ -96,55 +96,55 @@ def to_string(proto: Any, b: bytes) -> str:
9696

9797
# Register WebRTC protocols with multiaddr
9898
try:
99-
99+
100100
# Create codec instances
101101
webrtc_codec = WebRTCCodec()
102102
webrtc_direct_codec = WebRTCDirectCodec()
103103
certhash_codec = CerthashCodec()
104-
104+
105105
# Register codec modules for multiaddr
106106
sys.modules['multiaddr.codecs.webrtc'] = webrtc_codec # type: ignore
107107
sys.modules['multiaddr.codecs.webrtc_direct'] = webrtc_direct_codec # type: ignore
108108
sys.modules['multiaddr.codecs.certhash'] = certhash_codec # type: ignore
109-
109+
110110
setattr(codecs, 'webrtc', webrtc_codec)
111111
setattr(codecs, 'webrtc_direct', webrtc_direct_codec)
112112
setattr(codecs, 'certhash', certhash_codec)
113-
113+
114114
# Create Protocol objects with string codec names
115115
webrtc_protocol = Protocol(
116116
code=CODEC_WEBRTC,
117117
name=PROTOCOL_WEBRTC,
118-
codec="webrtc"
118+
codec="webrtc"
119119
)
120-
120+
121121
webrtc_direct_protocol = Protocol(
122122
code=CODEC_WEBRTC_DIRECT,
123123
name=PROTOCOL_WEBRTC_DIRECT,
124-
codec="webrtc_direct"
124+
codec="webrtc_direct"
125125
)
126-
126+
127127
certhash_protocol = Protocol(
128128
code=CODEC_CERTHASH,
129129
name=PROTOCOL_CERTHASH,
130-
codec="certhash"
130+
codec="certhash"
131131
)
132-
132+
133133
# Register protocols using the add_protocol function
134134
protocols.add_protocol(webrtc_protocol)
135135
protocols.add_protocol(webrtc_direct_protocol)
136136
protocols.add_protocol(certhash_protocol)
137-
137+
138138
print("✅ WebRTC protocols registered with multiaddr")
139-
139+
140140
except ImportError as e:
141141
print(f"⚠️ Failed to register WebRTC protocols: {e}")
142142
except Exception as e:
143143
print(f"⚠️ Error registering WebRTC protocols: {e}")
144144

145145
__all__ = [
146146
"WebRTCTransport",
147-
"WebRTCDirectTransport",
147+
"WebRTCDirectTransport",
148148
"DEFAULT_ICE_SERVERS",
149149
"SIGNALING_PROTOCOL",
150150
"MUXER_PROTOCOL",
@@ -159,11 +159,11 @@ def to_string(proto: Any, b: bytes) -> str:
159159
]
160160

161161

162-
def webrtc(config: Dict[str, Any] | None = None) -> WebRTCTransport:
162+
def webrtc(config: dict[str, Any] | None = None) -> WebRTCTransport:
163163
"""Create a WebRTC transport instance (private-to-private)."""
164164
return WebRTCTransport(config)
165165

166166

167-
def webrtc_direct(config: Dict[str, Any] | None = None) -> WebRTCDirectTransport:
167+
def webrtc_direct(config: dict[str, Any] | None = None) -> WebRTCDirectTransport:
168168
"""Create a WebRTC-Direct transport instance (private-to-public)."""
169-
return WebRTCDirectTransport(config)
169+
return WebRTCDirectTransport(config)

0 commit comments

Comments
 (0)