Skip to content

Commit 11a2627

Browse files
authored
Merge pull request #29 from faif/master
Syncing from upstream faif/python-patterns (master)
2 parents 400a612 + 4622c78 commit 11a2627

3 files changed

Lines changed: 1034 additions & 6 deletions

File tree

patterns/creational/factory.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def get_localizer(language: str = "English") -> Localizer:
5454
"Greek": GreekLocalizer,
5555
}
5656

57-
return localizers.get(language, EnglishLocalizer)()
58-
57+
return localizers.get(language, EnglishLocalizer)()
5958

6059

6160
def main():

patterns/structural/adapter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Allows the interface of an existing class to be used as another interface.
2929
"""
3030

31-
from typing import Callable, TypeVar
31+
from typing import Callable, TypeVar, Any, Dict
3232

3333
T = TypeVar("T")
3434

@@ -74,16 +74,16 @@ class Adapter:
7474
dog = Adapter(dog, make_noise=dog.bark)
7575
"""
7676

77-
def __init__(self, obj: T, **adapted_methods: Callable):
77+
def __init__(self, obj: T, **adapted_methods: Callable[..., Any]) -> None:
7878
"""We set the adapted methods in the object's dict."""
7979
self.obj = obj
8080
self.__dict__.update(adapted_methods)
8181

82-
def __getattr__(self, attr):
82+
def __getattr__(self, attr: str) -> Any:
8383
"""All non-adapted calls are passed to the object."""
8484
return getattr(self.obj, attr)
8585

86-
def original_dict(self):
86+
def original_dict(self) -> Dict[str, Any]:
8787
"""Print original object dict."""
8888
return self.obj.__dict__
8989

0 commit comments

Comments
 (0)