We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 063a422 commit 5072ddaCopy full SHA for 5072dda
named_annotations.py
@@ -0,0 +1,26 @@
1
+from abc import ABC, abstractmethod
2
+
3
4
+class AnnotationFactory(ABC):
5
+ """
6
+ Annotation factory class.
7
+ Creates annotation by input other.
8
9
+ Can be used via [] (preferred) or by normal call.
10
11
12
+ def __call__(self, annotation: any) -> any:
13
+ return self._create_full_annotation_by(annotation)
14
15
+ def __getitem__(self, annotation: any) -> any:
16
+ return self._create_full_annotation_by(
17
+ Union[annotation]
18
+ if isinstance(annotation, Iterable)
19
+ else annotation
20
+ )
21
22
+ @abstractmethod
23
+ def _create_full_annotation_by(self, annotation: any) -> any:
24
+ """Annotation Creation Method from an input annotation."""
25
26
0 commit comments