File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 4
4
class Flyweight (): # pylint: disable=too-few-public-methods
5
5
"The Flyweight that contains an intrinsic value called code"
6
6
7
- def __init__ (self , code : int ) -> None :
7
+ def __init__ (self , code : str ) -> None :
8
8
self .code = code
Original file line number Diff line number Diff line change @@ -9,21 +9,21 @@ class IFlyweight():
9
9
class Flyweight (IFlyweight ):
10
10
"The Concrete Flyweight"
11
11
12
- def __init__ (self , code : int ) -> None :
12
+ def __init__ (self , code : str ) -> None :
13
13
self .code = code
14
14
15
15
16
16
class FlyweightFactory ():
17
17
"Creating the FlyweightFactory as a singleton"
18
18
19
- _flyweights : dict [int , Flyweight ] = {} # Python 3.9
19
+ _flyweights : dict [str , Flyweight ] = {} # Python 3.9
20
20
# _flyweights = {} # Python 3.8 or earlier
21
21
22
22
def __new__ (cls ):
23
23
return cls
24
24
25
25
@classmethod
26
- def get_flyweight (cls , code : int ) -> Flyweight :
26
+ def get_flyweight (cls , code : str ) -> Flyweight :
27
27
"A static method to get a flyweight based on a code"
28
28
if not code in cls ._flyweights :
29
29
cls ._flyweights [code ] = Flyweight (code )
Original file line number Diff line number Diff line change 5
5
class FlyweightFactory ():
6
6
"Creating the FlyweightFactory as a singleton"
7
7
8
- _flyweights : dict [int , Flyweight ] = {} # Python 3.9
8
+ _flyweights : dict [str , Flyweight ] = {} # Python 3.9
9
9
# _flyweights = {} # Python 3.8 or earlier
10
10
11
11
def __new__ (cls ):
12
12
return cls
13
13
14
14
@classmethod
15
- def get_flyweight (cls , code : int ) -> Flyweight :
15
+ def get_flyweight (cls , code : str ) -> Flyweight :
16
16
"A static method to get a flyweight based on a code"
17
17
if not code in cls ._flyweights :
18
18
cls ._flyweights [code ] = Flyweight (code )
You can’t perform that action at this time.
0 commit comments