Skip to content

Passing a bool to expect_references always results in a singular result #278

@MatthiasValvekens

Description

@MatthiasValvekens

For the purpose of deciding whether verify(...) should return a list or a single result, the return line contains the following conditional:

return verify_results if self.config.expect_references > 1 else verify_results[0]

But if expect_references is a bool (which is allowed per the type signature) this conditional always evaluates to False, so only the first result is returned. This makes it difficult to work with signed documents in a context where the number of references is not fixed.

Since the docstring of expect_references states "if set to a non-integer, any number of references is accepted (otherwise a mismatch raises an error)", I don't think this is expected behaviour.

I would think replacing the above with this would result in a more intuitive return value:

return verify_results[0] if type(self.config.expect_references) is int and self.config.expect_references == 1 else verify_results

There's an argument that this is an API-breaking change, though (the test suite is also affected in at least one place).

WDYT?

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