Coverage for src/configuraptor/postpone.py: 100%

1"""

2 File contains logic to do with the 'postpone' feature.

3"""

4

5 import typing

6

7 from .errors import IsPostponedError

8 from .singleton import Singleton

9

10

11 class Postponed(Singleton):

12 """

13 Class returned by `postpone` below.

14 """

15

16 def __get__(self, instance: type[typing.Any], owner: type[typing.Any]) -> typing.Never:

17 """

18 This magic method is called when a property is accessed.

19

20 Example:

21 someclass.someprop will trigger the __get__ of `someprop`

22

23 Args:

24 instance: the class on which the postponed property is defined,

25 owner: `SingletonMeta`

26 """

27 raise IsPostponedError()

28

29

30 def postpone() -> typing.Any:

31 """

32 Can be used to mark a property as postponed, meaning the user will fill it in later (they promose).

33

34 If they don't fill it in and still try to use it, they will be met with a IsPostponedError.

35 """

36 return Postponed()