File tree Expand file tree Collapse file tree
AbstractFactory/Structural
ChainOfResponsibility/Structural Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212
1313
1414from __future__ import annotations
15- from abc import ABCMeta , abstractmethod
15+ from abc import ABC , abstractmethod
1616
1717
18- class AbstractFactory (metaclass = ABCMeta ):
18+ class AbstractFactory (ABC ):
1919 """
2020 EN: The Abstract Factory interface declares a set of methods that return
2121 different abstract products. These products are called a family and are
@@ -84,7 +84,7 @@ def create_product_b(self) -> ConcreteProductB2:
8484"""
8585
8686
87- class AbstractProductA (metaclass = ABCMeta ):
87+ class AbstractProductA (ABC ):
8888 @abstractmethod
8989 def useful_function_a (self ) -> str :
9090 pass
@@ -107,7 +107,7 @@ def useful_function_a(self) -> str:
107107 return "The result of the product A2."
108108
109109
110- class AbstractProductB (metaclass = ABCMeta ):
110+ class AbstractProductB (ABC ):
111111 """
112112 EN: Here's the the base interface of another product. All products can interact with
113113 each other, but proper interaction is possible only between products of the
Original file line number Diff line number Diff line change 1313
1414
1515from __future__ import annotations
16- from abc import ABCMeta , abstractmethod , abstractproperty
16+ from abc import ABC , abstractmethod , abstractproperty
1717from typing import Any
1818
1919
20- class Builder (metaclass = ABCMeta ):
20+ class Builder (ABC ):
2121 """
2222 EN: The Builder interface specifies methods for creating the different parts
2323 of the Product objects.
Original file line number Diff line number Diff line change 1414"""
1515
1616from __future__ import annotations
17- from abc import ABCMeta , abstractmethod
17+ from abc import ABC , abstractmethod
1818from typing import Any , Optional
1919
2020
21- class Handler (metaclass = ABCMeta ):
21+ class Handler (ABC ):
2222 """
2323 EN: The Handler interface declares a method for building the chain of
2424 handlers. It also declares a method for executing a request.
Original file line number Diff line number Diff line change 1414
1515
1616from __future__ import annotations
17- from abc import ABCMeta , abstractmethod
17+ from abc import ABC , abstractmethod
1818
1919
20- class Command (metaclass = ABCMeta ):
20+ class Command (ABC ):
2121 """
2222 EN: The Command interface declares a method for executing a command.
2323
Original file line number Diff line number Diff line change 1414
1515
1616from __future__ import annotations
17- from abc import ABCMeta , abstractmethod
17+ from abc import ABC , abstractmethod
1818
1919
20- class Creator (metaclass = ABCMeta ):
20+ class Creator (ABC ):
2121 """
2222 EN: The Creator class declares the factory method that is supposed to return
2323 an object of a Product class. The Creator's subclasses usually provide the
@@ -100,7 +100,7 @@ def factory_method(self) -> ConcreteProduct2:
100100 return ConcreteProduct2 ()
101101
102102
103- class Product (metaclass = ABCMeta ):
103+ class Product (ABC ):
104104 """
105105 EN: The Product interface declares the operations that all concrete products
106106 must implement.
Original file line number Diff line number Diff line change 1515
1616
1717from __future__ import annotations
18- from abc import ABCMeta
18+ from abc import ABC
1919
2020
21- class Mediator (metaclass = ABCMeta ):
21+ class Mediator (ABC ):
2222 """
2323 EN: The Mediator interface declares a method used by components to notify the
2424 mediator about various events. The Mediator may react to these events and
Original file line number Diff line number Diff line change 1313
1414
1515from __future__ import annotations
16- from abc import ABCMeta , abstractmethod
16+ from abc import ABC , abstractmethod
1717from datetime import datetime
1818from random import sample
1919from string import ascii_letters , digits
@@ -81,7 +81,7 @@ def restore(self, memento: Memento) -> None:
8181 print (f"Originator: My state has changed to: { self ._state } " )
8282
8383
84- class Memento (metaclass = ABCMeta ):
84+ class Memento (ABC ):
8585 """
8686 EN: The Memento interface provides a way to retrieve the memento's metadata,
8787 such as creation date or name. However, it doesn't expose the Originator's
Original file line number Diff line number Diff line change 2525
2626
2727from __future__ import annotations
28- from abc import ABCMeta , abstractmethod
28+ from abc import ABC , abstractmethod
2929from random import randrange
3030from typing import List
3131
3232
33- class Subject (metaclass = ABCMeta ):
33+ class Subject (ABC ):
3434 """
3535 EN: The Subject owns some important state and notifies observers when the
3636 state changes.
@@ -52,7 +52,7 @@ def notify(self) -> None:
5252 pass
5353
5454
55- class Observer (metaclass = ABCMeta ):
55+ class Observer (ABC ):
5656 @abstractmethod
5757 def update (self , subject : Subject ) -> None :
5858 pass
Original file line number Diff line number Diff line change 1212"""
1313
1414
15- from abc import ABCMeta , abstractmethod
15+ from abc import ABC , abstractmethod
1616
1717
18- class Subject (metaclass = ABCMeta ):
18+ class Subject (ABC ):
1919 """
2020 EN: The Subject interface declares common operations for both RealSubject and
2121 the Proxy. As long as the client works with RealSubject using this interface,
Original file line number Diff line number Diff line change 1212
1313
1414from __future__ import annotations
15- from abc import ABCMeta , abstractmethod
15+ from abc import ABC , abstractmethod
1616
1717
18- class Context (metaclass = ABCMeta ):
18+ class Context (ABC ):
1919 """
2020 EN: The Context defines the interface of interest to clients. It also
2121 maintains a reference to an instance of a State subclass, which represents
@@ -62,7 +62,7 @@ def request2(self):
6262 self ._state .handle2 ()
6363
6464
65- class State (metaclass = ABCMeta ):
65+ class State (ABC ):
6666 """
6767 EN: The base State class declares methods that all Concrete State should
6868 implement and also provides a backreference to the Context object, associated
You can’t perform that action at this time.
0 commit comments