From 1b084d56ca66d73ed05fd83b5657c0824f4b72c5 Mon Sep 17 00:00:00 2001 From: Ryan Ly Date: Fri, 4 Jun 2021 18:02:01 -0700 Subject: [PATCH] Fix postprocess set of fields in custom class generator (#626) * Fix postprocess set of fields in custom class generator * Update changelog * Update changelog --- CHANGELOG.md | 5 +++++ src/hdmf/build/__init__.py | 2 +- src/hdmf/build/classgenerator.py | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af8b8930b..a00a384ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # HDMF Changelog +## HDMF 2.5.7 (June 4, 2021) + +### Bug fix +- Fix generation of extension classes that extend MultiContainerInterface and use a custom _fieldsname. @rly (#626) + ## HDMF 2.5.6 (May 19, 2021) ### Bug fix diff --git a/src/hdmf/build/__init__.py b/src/hdmf/build/__init__.py index 5f467d916..ea5d21152 100644 --- a/src/hdmf/build/__init__.py +++ b/src/hdmf/build/__init__.py @@ -1,5 +1,5 @@ from .builders import Builder, DatasetBuilder, GroupBuilder, LinkBuilder, ReferenceBuilder, RegionBuilder -from .classgenerator import CustomClassGenerator +from .classgenerator import CustomClassGenerator, MCIClassGenerator from .errors import (BuildError, OrphanContainerBuildError, ReferenceTargetNotBuiltError, ContainerConfigurationError, ConstructError) from .manager import BuildManager, TypeMap diff --git a/src/hdmf/build/classgenerator.py b/src/hdmf/build/classgenerator.py index edd95a6e7..db4f326d3 100644 --- a/src/hdmf/build/classgenerator.py +++ b/src/hdmf/build/classgenerator.py @@ -268,9 +268,10 @@ def post_process(cls, classdict, bases, docval_args, spec): :param spec: The spec for the container class to generate. """ # convert classdict['__fields__'] from list to tuple if present - fields = classdict.get(bases[0]._fieldsname) - if fields is not None: - classdict[bases[0]._fieldsname] = tuple(fields) + for b in bases: + fields = classdict.get(b._fieldsname) + if fields is not None and not isinstance(fields, tuple): + classdict[b._fieldsname] = tuple(fields) # if spec provides a fixed name for this type, remove the 'name' arg from docval_args so that values cannot # be passed for a name positional or keyword arg