Skip to content

Commit

Permalink
Add: Allow to create gvm Enums from all kind of objects
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernricks authored and greenbonebot committed Jun 14, 2024
1 parent 6e4a475 commit 20bb19c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gvm/_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

from enum import Enum as PythonEnum
from typing import Optional
from typing import Any, Optional

from typing_extensions import Self

Expand All @@ -16,6 +16,10 @@ class Enum(PythonEnum):
Base class for Enums in python-gvm
"""

@classmethod
def _missing_(cls, value: Any) -> Optional[Self]:
return cls.from_string(str(value) if value else None)

@classmethod
def from_string(
cls,
Expand Down

0 comments on commit 20bb19c

Please sign in to comment.