Skip to content

Commit 172a08c

Browse files
no need for game to be a hidden attribute of CatalogGame classes
1 parent d9ac952 commit 172a08c

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/pygambit/catalog/catalog.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class CatalogGame:
2121
num_players: int
2222
game_type: Literal["nfg", "efg"]
2323
description: str
24-
_cached_game: Game | None = None
24+
game: Game | None = None
2525

2626
def __new__(cls, *args, **kwargs) -> Game:
2727
"""Create a game instance by calling the _game() method."""
28-
if cls._cached_game is None:
29-
cls._cached_game = cls._game(*args, **kwargs)
30-
return cls._cached_game
28+
if cls.game is None:
29+
cls.game = cls._game(*args, **kwargs)
30+
return cls.game
3131

3232
@staticmethod
3333
def _game() -> Game:
@@ -53,8 +53,8 @@ def __init_subclass__(cls, **kwargs):
5353
return
5454

5555
# Load game and extract metadata immediately when class is defined
56-
cls._cached_game = cls._game()
57-
cls._extract_metadata_from_game(cls._cached_game)
56+
cls.game = cls._game()
57+
cls._extract_metadata_from_game(cls.game)
5858

5959

6060
class CatalogGameFromContrib(CatalogGame):
@@ -67,9 +67,9 @@ class CatalogGameFromContrib(CatalogGame):
6767
game_file: str
6868

6969
def __new__(cls) -> Game:
70-
if cls._cached_game is None:
71-
cls._cached_game = cls._load_game()
72-
return cls._cached_game
70+
if cls.game is None:
71+
cls.game = cls._load_game()
72+
return cls.game
7373

7474
@classmethod
7575
def _load_game(cls) -> Game:
@@ -94,8 +94,8 @@ def __init_subclass__(cls, **kwargs):
9494
super().__init_subclass__(**kwargs)
9595

9696
# Load game and extract metadata immediately when class is defined
97-
cls._cached_game = cls._load_game()
98-
cls._extract_metadata_from_game(cls._cached_game)
97+
cls.game = cls._load_game()
98+
cls._extract_metadata_from_game(cls.game)
9999

100100

101101
def games(

0 commit comments

Comments
 (0)