From 6a9c0bd237c69ebe494fa83f34d23da44e3d34e2 Mon Sep 17 00:00:00 2001 From: Adam Hitchcock Date: Fri, 2 Oct 2026 12:35:29 -0700 Subject: [PATCH] Annotate tag()'s tag_mapping parameter Unannotated, strict type checkers (pyright strict) report every call to usaddress.tag as partially unknown. --- usaddress/__init__.py | 4 +++- usaddress/__init__.pyi | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/usaddress/__init__.py b/usaddress/__init__.py index 2628219..d576584 100644 --- a/usaddress/__init__.py +++ b/usaddress/__init__.py @@ -680,7 +680,9 @@ def parse(address_string: str) -> list[tuple[str, str]]: return list(zip(tokens, tags)) -def tag(address_string: str, tag_mapping=None) -> tuple[dict[str, str], str]: +def tag( + address_string: str, tag_mapping: typing.Optional[typing.Mapping[str, str]] = None +) -> tuple[dict[str, str], str]: tagged_components: dict[str, list] = {} last_label = None diff --git a/usaddress/__init__.pyi b/usaddress/__init__.pyi index 80e3a47..e1a7687 100644 --- a/usaddress/__init__.pyi +++ b/usaddress/__init__.pyi @@ -12,7 +12,9 @@ def parse(address_string: str) -> list[tuple[str, str]]: """ ... -def tag(address_string: str, tag_mapping=None) -> tuple[dict[str, str], str]: +def tag( + address_string: str, tag_mapping: typing.Optional[typing.Mapping[str, str]] = None +) -> tuple[dict[str, str], str]: """ Parse and merge consecutive components & strip commas. Also return an address type (`Street Address`, `Intersection`, `PO Box`, or `Ambiguous`).