Skip to content

Support Enum._missing_ hooks - #532

Merged
jcrist merged 1 commit into
mainfrom
enum-missing-support
Aug 24, 2023
Merged

jcrist merged 1 commit into
mainfrom
enum-missing-support

Conversation

@jcrist

@jcrist jcrist commented Aug 24, 2023

Copy link
Copy Markdown
Member

This adds support for Enum._missing_ hooks. This method is part of the standard library's enum implementation, and is called when a value isn't one defined directly on the Enum type. The method should return a valid enum member, or None if the value is invalid.

This may be used to support case-insensitive enums, or to coerce unknown values into a single "UNKNOWN" member.

Fixes #531.

This adds support for `Enum._missing_` hooks. This method is part of
the standard library's `enum` implementation, and is called when a value
isn't one defined directly on the `Enum` type. The method should return
a valid enum member, or `None` if the value is invalid.

This may be used to support case-insensitive enums, or to coerce unknown
values into a single "UNKNOWN" member.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enums: Support for default member / __missing__

1 participant