Skip to content

stub: add RepeatedLabelError to __init__.pyi#408

Open
c-tonneslan wants to merge 1 commit into
datamade:mainfrom
c-tonneslan:fix/stub-repeated-label-error
Open

stub: add RepeatedLabelError to __init__.pyi#408
c-tonneslan wants to merge 1 commit into
datamade:mainfrom
c-tonneslan:fix/stub-repeated-label-error

Conversation

@c-tonneslan
Copy link
Copy Markdown

@c-tonneslan c-tonneslan commented May 17, 2026

Closes #407.
Also fixes #398.

The runtime class lives in __init__.py but the .pyi added in #371 left it out, so any caller doing

try:
    usaddress.tag(s)
except usaddress.RepeatedLabelError as e:
    ...

gets a pyright reportAttributeAccessIssue (or mypy attr-defined) and has to suppress it. Adding the class to the stub fixes it. Pyright before vs. after on a minimal repro:

# before
error: "RepeatedLabelError" is not a known attribute of module "usaddress"  (reportAttributeAccessIssue)

# after
(no output)

pytest is still green (4972 / 4972 passing).

The class exists at runtime in __init__.py but the .pyi added in datamade#371
omits it, so catching usaddress.RepeatedLabelError now triggers a
reportAttributeAccessIssue under pyright and attr-defined under mypy.
Downstream users have been working around it with type: ignore.

Closes datamade#407.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
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.

Type stub __init__.pyi missing RepeatedLabelError class RepeatedLabelError is not a known attribute of module "usaddress"

1 participant