Skip to content

Implement Python Enum class on RealmRole to allow exhaustive match checks #12725

@touilleMan

Description

@touilleMan

e.g.

match realm.get_current_role_for(author_user_id):
case RealmRole.READER | None:
return VlobUpdateBadOutcome.AUTHOR_NOT_ALLOWED
case RealmRole.OWNER | RealmRole.MANAGER | RealmRole.CONTRIBUTOR:
pass
case unknown:
# TODO: Implement `Enum` on `RealmRole` so we can use `assert_never` here
assert False, unknown

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