Skip to content

Annotate tag()'s tag_mapping parameter - #412

Open
NorthIsUp wants to merge 1 commit into
datamade:mainfrom
NorthIsUp:type-tag-mapping
Open

NorthIsUp wants to merge 1 commit into
datamade:mainfrom
NorthIsUp:type-tag-mapping

Conversation

@NorthIsUp

@NorthIsUp NorthIsUp commented Oct 2, 2026 •

Copy link
Copy Markdown

Overview

tag() leaves tag_mapping unannotated in both __init__.py and the new __init__.pyi, so pyright in strict mode reports reportUnknownMemberType on every usaddress.tag(...) call (its signature is (address_string: str, tag_mapping: Unknown | None = None)).

This annotates it as Optional[Mapping[str, str]], matching the docstring ({'OldTag': 'NewTag'}) and the body, which only calls .get() on it. No runtime change.

Testing Instructions

  • mypy usaddress is clean
  • black --check . is clean
  • pytest tests: 4972 passed
  • In a project with pyright strict = true, usaddress.tag("123 Main St") no longer reports reportUnknownMemberType

Unannotated, strict type checkers (pyright strict) report every call to
usaddress.tag as partially unknown.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant