We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cc54961 commit ad6fd4bCopy full SHA for ad6fd4b
patterns/creational/factory.py
@@ -21,6 +21,14 @@
21
*TL;DR
22
Creates objects without having to specify the exact class.
23
"""
24
+fromtypingimportDict
25
+fromtypingimportProtocol
26
+fromtypingimportType
27
+
28
29
+classLocalizer(Protocol):
30
+deflocalize(self, msg: str) ->str:
31
+pass
32
33
34
classGreekLocalizer:
@@ -41,10 +49,10 @@ def localize(self, msg: str) -> str:
41
49
returnmsg
42
50
43
51
44
-defget_localizer(language: str="English") ->object:
52
+defget_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