Skip to content

Commit d3838eb

Browse files
Refactor tag-only protocol examples for clarity
- Updated the examples in `tag_only_examples.py` to improve address validation by using a placeholder variable for `Multiaddr` instantiation. - Enhanced error handling messages to provide clearer feedback on invalid addresses. These changes aim to streamline the usage examples and improve the overall clarity of error reporting for tag-only protocols.
1 parent b97991b commit d3838eb

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

examples/tag_only/tag_only_examples.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def basic_tag_only_usage():
117117
for proto_name in TAG_ONLY_PROTOCOLS[:5]: # Show first 5
118118
addr_str = f"/{proto_name}"
119119
try:
120-
ma = Multiaddr(addr_str)
120+
_ = Multiaddr(addr_str) # Validate the address
121121
print(f" {addr_str}")
122122
except Exception as e:
123123
print(f" {addr_str} - Error: {e}")
@@ -221,7 +221,7 @@ def common_tag_only_protocols():
221221

222222
for name, addr_str in examples:
223223
try:
224-
ma = Multiaddr(addr_str)
224+
_ = Multiaddr(addr_str) # Validate the address
225225
print(f"{name}: {addr_str}")
226226
except Exception as e:
227227
print(f"{name}: {addr_str} - Error: {e}")
@@ -295,4 +295,3 @@ def main():
295295

296296
if __name__ == "__main__":
297297
main()
298-

newsfragments/98.bugfix.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ Tag-only protocols like ``http``, ``https``, ``tls``, ``noise``, ``webrtc``, etc
33
now correctly reject invalid value assignments via both ``/tag/value`` and
44
``/tag=value`` syntax, raising clear error messages that do not include the
55
invalid value.
6-

0 commit comments

Comments
 (0)