Skip to content

Return type incorrect for XMLVerifier.verify when expect_references=1 #257

Open
@samueljsb

Description

The return type for this method is always a union of a single result or a list of results:

# t.py
import signxml

data = object()
result = signxml.XMLVerifier().verify(data, expect_references=1)
reveal_type(result)
$ mypy t.py
t.py:6: note: Revealed type is "Union[signxml.verifier.VerifyResult, builtins.list[signxml.verifier.VerifyResult]]"
Success: no issues found in 1 source file

However, when we only expect one result, we only get one result, so this annotation is unhelpful. Callers shouldn't need to handle the list case.

I believe this can be fixed with typing.overload.

Would a PR be welcome to make that change?

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