Add missing type hints to synapse.util (#9982)

This commit is contained in:
Patrick Cloke 2021-05-24 15:32:01 -04:00 committed by GitHub
parent 22a8838f62
commit 7adcb20fc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 39 additions and 25 deletions

View file

@ -17,19 +17,19 @@ import phonenumbers
from synapse.api.errors import SynapseError
def phone_number_to_msisdn(country, number):
def phone_number_to_msisdn(country: str, number: str) -> str:
"""
Takes an ISO-3166-1 2 letter country code and phone number and
returns an msisdn representing the canonical version of that
phone number.
Args:
country (str): ISO-3166-1 2 letter country code
number (str): Phone number in a national or international format
country: ISO-3166-1 2 letter country code
number: Phone number in a national or international format
Returns:
(str) The canonical form of the phone number, as an msisdn
The canonical form of the phone number, as an msisdn
Raises:
SynapseError if the number could not be parsed.
SynapseError if the number could not be parsed.
"""
try:
phoneNumber = phonenumbers.parse(number, country)