-
Notifications
You must be signed in to change notification settings - Fork 791
Description
Description
The line_type_intelligence field in PhoneNumberInstance for the Lookup v2 API is incorrectly typed as Optional[str] when it should be Optional[Dict].
I mainly noticed this as my linter was failing the type check of one of my files because it thought the field was string.
Current Behavior
The type annotation for line_type_intelligence is:
twilio-python/twilio/rest/lookups/v2/phone_number.py
Lines 70 to 72 in 615fb81
| self.line_type_intelligence: Optional[str] = payload.get( | |
| "line_type_intelligence" | |
| ) |
Expected Behavior
According to the official Twilio documentation, line_type_intelligence should be typed as:
line_type_intelligence: Optional[Dict[str, Any]]Evidence from Official Documentation
The Twilio Lookup v2 Line Type Intelligence documentation clearly shows that line_type_intelligence is an object (dictionary) containing the following properties:
mobile_country_code(string)mobile_network_code(string)carrier_name(string)type(string)error_code(nullable)
Example response from the official docs:
"line_type_intelligence": {
"error_code": null,
"mobile_country_code": "240",
"mobile_network_code": "38",
"carrier_name": "Twilio - SMS/MMS-SVR",
"type": "nonFixedVoip"
}Impact
This incorrect typing can lead to:
- Type checking errors when accessing nested properties (e.g.,
phone_number.line_type_intelligence["type"])
If possible, I'd like to make this change and contribute.