twilio / twilio/twilio-python

Incorrect type annotation for line_type_intelligence in PhoneNumberInstance (Lookup v2)

Open Beginner friendly
#883 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.1k
Forks
815
Avg merge
2d 13h
Merged PRs (30d)
2

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:
https://github.com/twilio/twilio-python/blob/615fb812590f0481b75a11f89842874eb6858973/twilio/rest/lookups/v2/phone_number.py#L70-L72

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in twilio/rest/lookups/v2/phone_number.py around lines 70–72, where PhoneNumberInstance declares line_type_intelligence. Compare the annotation with the linked Lookup v2 documentation and update it to represent the documented object shape. The issue is done when the field accepts the nested dictionary response without the reported type-checking error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.