Coverage for src/configuraptor/postpone.py: 100%
8 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-15 14:30 +0200
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-15 14:30 +0200
1"""
2File contains logic to do with the 'postpone' feature.
3"""
5import typing
7from .errors import IsPostponedError
8from .singleton import Singleton
11class Postponed(Singleton):
12 """
13 Class returned by `postpone` below.
14 """
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.
20 Example:
21 someclass.someprop will trigger the __get__ of `someprop`
23 Args:
24 instance: the class on which the postponed property is defined,
25 owner: `SingletonMeta`
26 """
27 raise IsPostponedError()
30def postpone() -> typing.Any:
31 """
32 Can be used to mark a property as postponed, meaning the user will fill it in later (they promose).
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()