Skip to content

Commit 24fe1f3

Browse files
committed
Flag abstract base class
1 parent d2e2423 commit 24fe1f3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

plain-flags/plain/flags/flags.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from abc import ABC, abstractmethod
23
from functools import cached_property
34
from typing import Any
45

@@ -21,7 +22,8 @@
2122
tracer = trace.get_tracer("plain.flags")
2223

2324

24-
class Flag:
25+
class Flag(ABC):
26+
@abstractmethod
2527
def get_key(self) -> Any:
2628
"""
2729
Determine a unique key for this instance of the flag.
@@ -32,8 +34,9 @@ def get_key(self) -> Any:
3234
3335
Return a falsy value if you don't want to store the flag result.
3436
"""
35-
raise NotImplementedError
37+
...
3638

39+
@abstractmethod
3740
def get_value(self) -> Any:
3841
"""
3942
Compute the resulting value of the flag.
@@ -43,7 +46,7 @@ def get_value(self) -> Any:
4346
If get_key() returns a value, this will only be called once per key
4447
and then subsequent calls will return the saved value from the DB.
4548
"""
46-
raise NotImplementedError
49+
...
4750

4851
def get_db_name(self) -> str:
4952
"""

0 commit comments

Comments
 (0)