#!/usr/bin/env python3
"""
Test script to demonstrate IDE autocomplete and type hints for up_py.

When you open this file in an IDE like VS Code or PyCharm with Python
language support, you should get:
- Autocomplete suggestions for all up_py classes and methods
- Type hints and parameter information
- Inline documentation when hovering over functions
"""

import up_py
from up_py import SimplePublisher

# Test 1: Creating a URI provider
# Type "up_py." and your IDE should show all available classes
uri_provider = up_py.StaticUriProvider("my-device", 0x1234, 0x01)

# Test 2: Creating transport
# Hovering over LocalTransport should show the docstring
transport = up_py.LocalTransport()

# Test 3: Creating publisher
# IDE should show parameter hints: (transport: LocalTransport, uri_provider: StaticUriProvider)
publisher = up_py.SimplePublisher(transport, uri_provider)

# Test 4: Creating payload
# Type "up_py.UPayload." and IDE should show: from_string, from_bytes
payload = up_py.UPayload.from_string("Hello, World!")

# Test 5: Defining a callback with proper type hints
def message_handler(msg: up_py.UMessage) -> None:
    """
    Handle incoming messages.
    
    When you type "msg." your IDE should suggest: extract_string()
    """
    # Type "msg." here and see autocomplete
    text = msg.extract_string()
    if text:
        print(f"Received: {text}")

# Test 6: Register listener with type hints
# IDE should validate that message_handler matches the expected signature
transport.register_listener(uri_provider, 0xb4c1, message_handler)

# Test 7: Publishing with type hints
# IDE should show: publish(resource_id: int, payload: UPayload | None)
publisher.publish(0xb4c1, payload)

# Test 8: Optional payload (None is valid)
publisher.publish(0xb4c1, None)

print("✅ All type-checked operations completed successfully!")
print("\nIDE Features Available:")
print("- Autocomplete for all classes and methods")
print("- Parameter type hints")
print("- Return type hints")
print("- Inline documentation")
print("- Type checking for function signatures")
