Skip to content

Commit

Permalink
corrected dataclass mutable default error
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Goldbach committed Mar 5, 2024
1 parent 6f5f3a2 commit 26dc0ba
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pyfoamd/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,8 @@ class _ofCaseBase(_ofTypeBase):
# _name : str = field(default=Path.cwd().name)
# _times : ofTimeReg = field(init=False, default=ofTimeReg())
# _registry : list = _populateRegistry(path)
constant : _ofFolderBase = field(init=False)
system : _ofFolderBase = field(init=False)
constant : _ofFolderBase = field(default_factory=_ofFolderBase, init=False)
system : _ofFolderBase = field(default_factory=_ofFolderBase, init=False)

def __post_init__(self):
#self._path = Path(self._location) / self._name
Expand Down Expand Up @@ -1070,9 +1070,16 @@ def makeOFCase(self):

# folderPath_ = self.path / obj.name
folderPath_ = obj.name
attrList.append((name_, _ofFolderBase,
field(default=FolderParser(
self.path, folderPath_).makeOFFolder())))
attrList.append(
(
name_, _ofFolderBase,
field(
default_factory=FolderParser(
self.path, folderPath_
).makeOFFolder
)
)
)

# dc_ = make_dataclass('ofCase', attrList,
# bases=(_ofCaseBase, ))(
Expand Down

0 comments on commit 26dc0ba

Please sign in to comment.