Skip to content

Commit 3045227

Browse files
committed
updates
1 parent 27ae281 commit 3045227

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

flyweight/flyweight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
class Flyweight(): # pylint: disable=too-few-public-methods
55
"The Flyweight that contains an intrinsic value called code"
66

7-
def __init__(self, code: int) -> None:
7+
def __init__(self, code: str) -> None:
88
self.code = code

flyweight/flyweight_concept.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ class IFlyweight():
99
class Flyweight(IFlyweight):
1010
"The Concrete Flyweight"
1111

12-
def __init__(self, code: int) -> None:
12+
def __init__(self, code: str) -> None:
1313
self.code = code
1414

1515

1616
class FlyweightFactory():
1717
"Creating the FlyweightFactory as a singleton"
1818

19-
_flyweights: dict[int, Flyweight] = {} # Python 3.9
19+
_flyweights: dict[str, Flyweight] = {} # Python 3.9
2020
# _flyweights = {} # Python 3.8 or earlier
2121

2222
def __new__(cls):
2323
return cls
2424

2525
@classmethod
26-
def get_flyweight(cls, code: int) -> Flyweight:
26+
def get_flyweight(cls, code: str) -> Flyweight:
2727
"A static method to get a flyweight based on a code"
2828
if not code in cls._flyweights:
2929
cls._flyweights[code] = Flyweight(code)

flyweight/flyweight_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
class FlyweightFactory():
66
"Creating the FlyweightFactory as a singleton"
77

8-
_flyweights: dict[int, Flyweight] = {} # Python 3.9
8+
_flyweights: dict[str, Flyweight] = {} # Python 3.9
99
# _flyweights = {} # Python 3.8 or earlier
1010

1111
def __new__(cls):
1212
return cls
1313

1414
@classmethod
15-
def get_flyweight(cls, code: int) -> Flyweight:
15+
def get_flyweight(cls, code: str) -> Flyweight:
1616
"A static method to get a flyweight based on a code"
1717
if not code in cls._flyweights:
1818
cls._flyweights[code] = Flyweight(code)

0 commit comments

Comments
 (0)