Skip to content

OneOf fields not typed as optional in constructor #580

@aidandj

Description

@aidandj

Given this proto:

enum Enum {
    UNKNOWN=0;
    KNOWN=1;
}
message WithOneOfs {
    oneof optional_enum {
        Enum some_enum = 1;
    }
}

The constructor looks something like this:

    def __init__(
        self,
        *,
        some_enum: global___Enum.ValueType = ...,
    ) -> None: ...

But the OneOf block is effectively marking the some_enum field as optional, but type checkers error when you try and pass None to the constructor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions