Skip to content

Type stub __init__.pyi missing RepeatedLabelError class #407

@wbarrett32

Description

@wbarrett32

The inline type stub at usaddress/__init__.pyi (added per #371) defines parse, tag, tokenize, etc., but omits the RepeatedLabelError exception class.

The class exists at runtime in __init__.py:

class RepeatedLabelError(probableparsing.RepeatedLabelError):
    REPO_URL = "https://github.com/datamade/usaddress/issues/new"
    DOCS_URL = "https://usaddress.readthedocs.io/"

Because the stub omits it, code that catches the exception triggers a type-checker error (pyright reportAttributeAccessIssue, mypy attr-defined):

import usaddress
try:
    usaddress.tag("...")
except usaddress.RepeatedLabelError:  # error: not a known attribute of module "usaddress"
    pass

This forces downstream users to add # type: ignore / # pyright: ignore purely to work around a stub gap.

Suggested fix — add to __init__.pyi:

import probableparsing

class RepeatedLabelError(probableparsing.RepeatedLabelError):
    REPO_URL: str
    DOCS_URL: str
    message: str
    original_string: str
    parsed_string: list[tuple[str, str]]

(The __init__ signature is inherited from probableparsing.RepeatedLabelError(original_string, parsed_string, repeated_label).)

Version: usaddress 0.5.16, Python 3.13.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions