summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHernan <hernan.grecco@gmail.com>2022-05-19 13:16:11 -0300
committerHernan <hernan.grecco@gmail.com>2022-05-19 13:16:11 -0300
commitb7ebed3e7c2da031e94914890fb316655308b756 (patch)
treed27760620d8c920ad93a97be540c1f059b5e416a
parent306907348754fd7ff90d70f6b9889a7cfd8a5a70 (diff)
downloadpint-b7ebed3e7c2da031e94914890fb316655308b756.tar.gz
Change build_dependent_class to only include bases defined in the actual registry
Prior to this commit, the facet registries could not be built correctly as the dependent classes mro will not be properly ordered.
-rw-r--r--pint/util.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/pint/util.py b/pint/util.py
index 2b95765..25b405b 100644
--- a/pint/util.py
+++ b/pint/util.py
@@ -1106,11 +1106,13 @@ def build_dependent_class(registry_class, class_name: str, attribute_name: str)
"""
bases = (
- getattr(base, attribute_name, None) for base in inspect.getmro(registry_class)
+ getattr(base, attribute_name)
+ for base in inspect.getmro(registry_class)
+ if attribute_name in base.__dict__
)
- bases = dict.fromkeys((base for base in bases if base), None)
-
- return type(class_name, tuple(bases.keys()), dict())
+ bases = dict.fromkeys(bases, None)
+ newcls = type(class_name, tuple(bases.keys()), dict())
+ return newcls
def create_class_with_registry(registry, base_class) -> Type: