Skip to content

Incorrect type annotation for identity_match in PhoneNumberInstance (Lookup v2) #930

Description

@ske99ey

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:

self.identity_match: Optional[str] = payload.get("identity_match")

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"])

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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