Skip to content

Commit

Permalink
fix format phone return
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto committed May 9, 2024
1 parent 840035f commit 03288db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion brazilfiscalreport/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def get_tag_text(node=None, url="", tag=None):


def format_phone(phone):
if not phone:
return ""

Check warning on line 18 in brazilfiscalreport/utils.py

View check run for this annotation

Codecov / codecov/patch

brazilfiscalreport/utils.py#L18

Added line #L18 was not covered by tests
try:
phone_number = phonenumbers.parse(phone, "BR")
if phonenumbers.region_code_for_number(phone_number) == "BR":
Expand All @@ -24,10 +26,10 @@ def format_phone(phone):
formatted_number = phonenumbers.format_number(
phone_number, PhoneNumberFormat.INTERNATIONAL
)
return formatted_number
except Exception as e:
warnings.warn(f"An error occurred: {e}", UserWarning, stacklevel=2)
formatted_number = phone
return formatted_number


def format_cep(cep):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="BrazilFiscalReport",
version="0.3.2",
version="0.3.3",
long_description="""
Python library for generating Brazilian auxiliary
fiscal documents in PDF from XML documents.
Expand Down

0 comments on commit 03288db

Please sign in to comment.