twilio / twilio/twilio-python

Incorrect type annotation for identity_match in PhoneNumberInstance (Lookup v2)

Open Beginner friendly
#930 0 comments 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 identity_match field in PhoneNumberInstance for the Lookup v2 API is incorrectly typed as Optional[str] when it should be Optional[Dict].

I noticed this as my linter was failing the type check of one of my files while performing the update from v8 to v9 because it thought the field was a string.

Current Behavior

The type annotation for identity_match is:
https://github.com/twilio/twilio-python/blob/9f783d960de38e470cd677ef0eaea011ef860005/twilio/rest/lookups/v2/phone_number.py#L77

Expected Behavior

According to the official Twilio documentation, identity_match should be typed as:

identity_match: Optional[Dict[str, Any]]
Evidence from Official Documentation

The Twilio Lookup v2 Line Type Intelligence documentation clearly shows that identity_match is an object (dictionary).

Example response from the official docs:

"identity_match": {
    "first_name_match": "exact_match",
    "last_name_match": "high_partial_match",
    "address_lines_match": "no_match",
    "city_match": "no_match",
    "state_match": "high_partial_match",
    "postal_code_match": "no_data_available",
    "address_country_match": "exact_match",
    "national_id_match": "exact_match",
    "date_of_birth_match": "exact_match",
    "summary_score": 90,
    "error_code": null,
    "error_message": null
},
Impact

This incorrect typing leads to:

  • Type checking errors when accessing nested properties (e.g., phone_number.identity_match["summary_score"])

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 line 77, where the identity_match annotation is defined. Change the annotation to Optional[Dict[str, Any]] and verify that type checking permits access to nested values such as summary_score.

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
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.