Skip to content

Incorrect type annotation for line_type_intelligence in PhoneNumberInstance (Lookup v2) #883

@1nF0rmed

Description

@1nF0rmed

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions