We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cc54961 + ad6fd4b commit 93bfb7fCopy full SHA for 93bfb7f
patterns/creational/factory.py
@@ -21,6 +21,14 @@
21
*TL;DR
22
Creates objects without having to specify the exact class.
23
"""
24
+from typing import Dict
25
+from typing import Protocol
26
+from typing import Type
27
+
28
29
+class Localizer(Protocol):
30
+ def localize(self, msg: str) -> str:
31
+ pass
32
33
34
class GreekLocalizer:
@@ -41,10 +49,10 @@ def localize(self, msg: str) -> str:
41
49
return msg
42
50
43
51
44
-def get_localizer(language: str = "English") -> object:
52
+def get_localizer(language: str = "English") -> Localizer:
45
53
46
54
"""Factory"""
47
- localizers = {
55
+ localizers: Dict[str, Type[Localizer]] = {
48
56
"English": EnglishLocalizer,
57
"Greek": GreekLocalizer,
58
}
0 commit comments