Skip to content

Fix the type annotation of GroupedMetadata.__iter__ #66

@Zac-HD

Description

@Zac-HD

Our README says that GroupedMetadata should be handled by iterating over the object and treating the results as if they had been "unpacked" in the Annotated type. However, the docstring is specific to BaseMetadata, as is the type annotation:

"""A grouping of multiple BaseMetadata objects.
`GroupedMetadata` on its own is not metadata and has no meaning.
All of the constraints and metadata should be fully expressable
in terms of the `BaseMetadata`'s returned by `GroupedMetadata.__iter__()`.

def __iter__(self) -> Iterator[BaseMetadata]:
...

The README is correct here, since we want to match typing.Unpack, so we should update the docstring to describe it as 'a grouping of multiple objects, like typing.Unpack', and annotate the iterable as containing object.

(originally identified in this downstream issue: HypothesisWorks/hypothesis#3986 (comment))

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